結果
問題 | No.60 魔法少女 |
ユーザー |
![]() |
提出日時 | 2017-05-11 04:13:52 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,090 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 44,160 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-09-15 07:33:46 |
合計ジャッジ時間 | 2,086 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d%d%d", &x, &y, &ene[i].hp); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:40:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%d%d%d%d%d", &x, &y, &w, &h, &d); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<vector> using namespace std; struct enemy_t { int x, y, hp, f; }; vector<enemy_t> ene; int main(void) { int i, n, k; int x, y, w, h, d; int ans; vector<vector<int> > f; while(scanf("%d%d", &n, &k)==2) { f.clear(); f.resize(1001); for(auto& fe: f) fe.resize(1001); ene.resize(n); for(i=0;i<n;i++) { scanf("%d%d%d", &x, &y, &ene[i].hp); ene[i].x=x+500; ene[i].y=y+500; ene[i].f=-1; } for(i=0;i<k;i++) { scanf("%d%d%d%d%d", &x, &y, &w, &h, &d); x+=500; y+=500; f[y][x]=+d; if(x+w+1<=1000) f[y ][x+w+1]-=d; if(y+h+1<=1000) f[y+h+1][x ]-=d; if(x+w+1<=1000 && y+h+1<=1000) f[y+h+1][x+w+1]+=d; } for(y=0;y<=1000;y++) { for(x=1;x<=1000;x++) { f[y][x]+=f[y][x-1]; } } for(y=1;y<=1000;y++) { for(x=0;x<=1000;x++) { f[y][x]+=f[y-1][x]; } } ans=0; for(i=0;i<n;i++) { enemy_t& t=ene[i]; ans+=max(0, t.hp-f[t.y][t.x]); } /* for(auto t: ene) printf("%d ", t.hp); printf("\n"); */ printf("%d\n", ans); } return 0; }