結果
問題 | No.60 魔法少女 |
ユーザー | imulan |
提出日時 | 2016-07-19 00:13:42 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 84 ms / 5,000 ms |
コード長 | 1,351 bytes |
コンパイル時間 | 1,943 ms |
コンパイル使用メモリ | 165,484 KB |
実行使用メモリ | 12,468 KB |
最終ジャッジ日時 | 2024-04-23 16:37:51 |
合計ジャッジ時間 | 3,103 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
11,592 KB |
testcase_01 | AC | 12 ms
11,468 KB |
testcase_02 | AC | 12 ms
11,592 KB |
testcase_03 | AC | 11 ms
11,476 KB |
testcase_04 | AC | 48 ms
11,808 KB |
testcase_05 | AC | 52 ms
12,468 KB |
testcase_06 | AC | 81 ms
12,324 KB |
testcase_07 | AC | 62 ms
12,028 KB |
testcase_08 | AC | 40 ms
11,900 KB |
testcase_09 | AC | 22 ms
11,832 KB |
testcase_10 | AC | 79 ms
12,356 KB |
testcase_11 | AC | 15 ms
11,744 KB |
testcase_12 | AC | 38 ms
12,028 KB |
testcase_13 | AC | 84 ms
12,272 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define mp make_pair #define pb push_back #define fi first #define se second //座標(x,y)に合計で入るダメージ ll dm[1002][1002]={0}; int main() { int n,k; cin >>n >>k; vector<int> x(n),y(n),hp(n); rep(i,n) { scanf(" %d %d %d", &x[i], &y[i], &hp[i]); //すべて第1象限で考えるために平行移動 x[i]+=500; y[i]+=500; } rep(i,k) { int ax,ay,w,h,d; scanf(" %d %d %d %d %d", &ax, &ay, &w, &h, &d); //平行移動 ax+=500; ay+=500; int rx=min(1000,ax+w); int ry=min(1000,ay+h); dm[ax][ay]+=d; dm[rx+1][ay]-=d; dm[ax][ry+1]-=d; dm[rx+1][ry+1]+=d; } //x方向に足し合わせる rep(i,1002) { for(int j=1; j<1002; ++j) dm[j][i]+=dm[j-1][i]; } //y方向に足し合わせる rep(i,1002) { for(int j=1; j<1002; ++j) dm[i][j]+=dm[i][j-1]; } ll ans=0; rep(i,n) { ll rem=hp[i]-dm[x[i]][y[i]]; if(rem>0) ans+=rem; } cout << ans << endl; return 0; }