結果
問題 | No.60 魔法少女 |
ユーザー | cormoran |
提出日時 | 2016-09-29 21:44:07 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 91 ms / 5,000 ms |
コード長 | 1,469 bytes |
コンパイル時間 | 1,374 ms |
コンパイル使用メモリ | 165,716 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-05-01 07:50:30 |
合計ジャッジ時間 | 2,833 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
11,136 KB |
testcase_01 | AC | 12 ms
11,136 KB |
testcase_02 | AC | 11 ms
11,008 KB |
testcase_03 | AC | 12 ms
11,008 KB |
testcase_04 | AC | 55 ms
11,136 KB |
testcase_05 | AC | 56 ms
12,032 KB |
testcase_06 | AC | 90 ms
12,160 KB |
testcase_07 | AC | 67 ms
11,904 KB |
testcase_08 | AC | 46 ms
11,648 KB |
testcase_09 | AC | 26 ms
11,264 KB |
testcase_10 | AC | 84 ms
12,160 KB |
testcase_11 | AC | 19 ms
11,392 KB |
testcase_12 | AC | 41 ms
11,776 KB |
testcase_13 | AC | 91 ms
12,160 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, j) for(int i=0; i < (int)(j); i++) #define repeat(i, j, k) for(int i = (j); i < (int)(k); i++) template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; } class Solver { public: bool solve() { int N, K; cin >> N >> K; vector<vector<ll>> G(1001, vector<ll>(1001, 0)); vector<int> X(N), Y(N), HP(N); rep(i, N) { cin >> X[i] >> Y[i] >> HP[i]; X[i] += 500; Y[i] += 500; assert(0 <= X[i] and X[i] <= 1000); assert(0 <= Y[i] and Y[i] <= 1000); } rep(i, K) { int ax, ay, w, h, d; cin >> ax >> ay >> w >> h >> d; ax += 500; ay += 500; G[ay][ax] += d; int ex = ax + w + 1; int ey = ay + h + 1; if(ex <= 1000) G[ay][ex] -= d; if(ey <= 1000) G[ey][ax] -= d; if(ex <= 1000 and ey <= 1000) G[ey][ex] += d; } rep(y, 1001) rep(x, 1001 -1) G[y][x + 1] += G[y][x]; rep(x, 1001) rep(y, 1001 - 1) G[y + 1][x] += G[y][x]; ll ans = 0; rep(i, N) { ans += max(0LL, HP[i] - G[Y[i]][X[i]]); } cout << ans << endl; return 0; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); Solver s; s.solve(); return 0; }