結果
問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
ユーザー |
![]() |
提出日時 | 2025-02-26 21:37:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 71 ms / 4,000 ms |
コード長 | 957 bytes |
コンパイル時間 | 1,684 ms |
コンパイル使用メモリ | 164,268 KB |
実行使用メモリ | 11,964 KB |
最終ジャッジ日時 | 2025-02-26 21:37:05 |
合計ジャッジ時間 | 4,709 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%lld%lld%lld",&n,&w,&h); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%lld%lld%lld",&a,&b,&x); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> #define FL(i,a,b) for(ll i=(a);i<=(b);i++) #define FR(i,a,b) for(ll i=(a);i>=(b);i--) #define ll long long #define PII pair<ll,ll> using namespace std; const ll MAXN = 1e5 + 10; ll n,w,h,sum[2]; vector<PII>E[MAXN]; struct BIT{ #define lowbit(x) x&(-x) ll c[MAXN]; void update(ll x,ll k){ while(x<=n){ c[x]+=k; x+=lowbit(x); } } ll query(ll x){ ll res=0; while(x){ res+=c[x]; x-=lowbit(x); } return res; } }T; signed main(){ scanf("%lld%lld%lld",&n,&w,&h); FL(i,1,n){ ll a,b,x; scanf("%lld%lld%lld",&a,&b,&x); E[x].push_back({i,b}); E[x+a].push_back({i,-b}); } FL(i,1,w){ for(PII j:E[i]) T.update(j.first,j.second); ll l=1,r=n,ans=-1; while(l<=r){ ll mid=(l+r)>>1; if(T.query(mid)>=h) ans=mid,r=mid-1; else l=mid+1; } if(ans!=-1) sum[ans&1]++; } if(sum[1]>sum[0]) puts("A"); else if(sum[1]<sum[0]) puts("B"); else puts("DRAW"); // printf("%lld %lld\n",sum[1],sum[0]); }