zoukankan      html  css  js  c++  java
  • codeforces282B

    div2B 贪心随便爆一遍就ok了

    #include <bits/stdc++.h>
    using namespace std;
    typedef int ll;
    inline ll read()
    {
        ll s=0; bool f=0; char ch=' ';
        while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
        while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
        return (f)?(-s):(s);
    }
    #define R(x) x=read()
    inline void write(ll x)
    {
        if(x<0) {putchar('-'); x=-x;}
        if(x<10) {putchar(x+'0'); return;}
        write(x/10); putchar((x%10)+'0');
    }
    #define W(x) write(x),putchar(' ')
    #define Wl(x) write(x),putchar('
    ')
    const int N=1000005;
    int n,A[N],G[N];
    char wwx[N];
    inline int sb(int x,int y);
    int main()
    {
        freopen("codeforces.in","r",stdin);
        int i,wn=0,wq=0;
        R(n);
        for(i=1;i<=n;i++)
        {
            R(A[i]); R(G[i]);
        }
        for(i=1;i<=n;i++)
        {
            if(sb(wn+A[i],wq)<sb(wn,wq+G[i]))
            {
                wn+=A[i];
                wwx[i]='A';
            }
            else
            {
                wq+=G[i];
                wwx[i]='G';
            }
            if(sb(wn,wq)>500)
            {
                puts("-1");
                return 0;
            }
        }
        for(i=1;i<=n;i++) putchar(wwx[i]); putchar('
    ');
        return 0;
    }
    inline int sb(int x,int y)
    {
        return abs(x-y);
    }
    View Code
    河田は河田、赤木は赤木……。 私は誰ですか。教えてください、私は誰ですか。 そうだ、俺はあきらめない男、三井寿だ!
  • 相关阅读:
    附近地点搜索 ,地图
    网站访问量
    后台全选功能以及数据的提交方法
    首页banner特效
    等待加载提示
    缩略图轮播
    遍历input。select option 选中的值
    django1补充
    pythonweb框架django框架1
    图书馆管理系统的页面设计
  • 原文地址:https://www.cnblogs.com/gaojunonly1/p/15456495.html
Copyright © 2011-2022 走看看