結果
問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
ユーザー |
![]() |
提出日時 | 2017-04-28 23:45:24 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 879 bytes |
コンパイル時間 | 241 ms |
コンパイル使用メモリ | 24,192 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-09-13 18:41:20 |
合計ジャッジ時間 | 6,327 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 1 |
other | AC * 1 WA * 23 TLE * 1 -- * 7 |
コンパイルメッセージ
main.cpp: In function ‘int solve()’: main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%d%d%d", &a, &b, &x); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<cstring> typedef long long ll; int n, w; ll h; ll bh[100000+1]; int solve(void) { int a, b, x, i, j, ret=-1, rest; int score[2]={0, 0}; rest=w; memset(bh, 0, sizeof(bh)); for(i=0;i<n;i++) { scanf("%d%d%d", &a, &b, &x); if(ret>=0) break; for(j=x+a-1;j>0;j--) { if(bh[j]<h) { bh[j]+=b; if(bh[j]>=h) { score[i%2]++; rest--; if(!rest) { if(score[0]==score[1]) ret=0; if(score[0]>score[1]) ret=1; if(score[0]<score[1]) ret=2; } } } } } /* printf("n=%d h=%lld w=%d\n", n, h, w); printf("score=(%d,%d) ret=%d\n", score[0], score[1], ret); for(j=1;j<=w;j++) printf("%lld ", bh[j]); printf("\n"); */ return ret; } int main(void) { char result[][5]={"DRAW", "A", "B"}; while(scanf("%d%d%lld", &n, &w, &h)==3) { printf("%s\n", result[solve()]); } return 0; }