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
    河田は河田、赤木は赤木……。 私は誰ですか。教えてください、私は誰ですか。 そうだ、俺はあきらめない男、三井寿だ!
  • 相关阅读:
    Python使用笔记20--网络操作小练习
    python使用笔记19--网络操作
    python使用笔记18--写日志
    python使用笔记17--异常处理
    python使用笔记16--操作redis
    列车调度
    三角形
    点亮灯笼
    数据读取
    codevs 1243 网络提速
  • 原文地址:https://www.cnblogs.com/gaojunonly1/p/15456495.html
Copyright © 2011-2022 走看看