結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー vjudge1
提出日時 2025-02-23 14:32:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 83 ms / 4,000 ms
コード長 948 bytes
コンパイル時間 1,752 ms
コンパイル使用メモリ 165,412 KB
実行使用メモリ 10,132 KB
最終ジャッジ日時 2025-02-23 14:32:07
合計ジャッジ時間 4,003 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#define DEBUG
const int N=1e5+10; long long c[N]; std::vector<std::pair<int,int> >v[N];
void add(int x,int y) { for(;x<N;x+=x&-x) c[x]+=y; }
long long sum(int x) { long long ans=0; for(;x;x-=x&-x) ans+=c[x]; return ans; }
int main() {
    //freopen("game.in","r",stdin);
    //freopen("game.out","w",stdout);
    std::ios::sync_with_stdio(false),std::cin.tie(nullptr);
    int n,w,a=0,b=0; long long h; std::cin>>n>>w>>h;
    for(int i=1,a,b,x;i<=n;i++) std::cin>>a>>b>>x,v[x].push_back({i,b}),v[x+a].push_back({i,-b});
    for(int i=1;i<=w;i++) {
        for(auto j:v[i]) add(j.first,j.second);
        int l=1,r=n,ans=0;
        while(l<=r) {
            int m=(l+r)>>1;
            if(sum(m)>=h) ans=m,r=m-1;
            else l=m+1;
        }
        if(ans) (ans&1?a++:b++);
    }
    if(a>b) std::cout<<'A';
    if(a<b) std::cout<<'B';
    if(a==b) std::cout<<"DRAW";
    //std::cout<<'\n'<<a<<' '<<b;
    return 0;
}
0