結果
問題 | No.60 魔法少女 |
ユーザー | cormoran |
提出日時 | 2016-09-29 21:44:07 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 75 ms / 5,000 ms |
コード長 | 1,469 bytes |
コンパイル時間 | 1,074 ms |
コンパイル使用メモリ | 151,176 KB |
実行使用メモリ | 12,100 KB |
最終ジャッジ日時 | 2023-08-13 14:55:00 |
合計ジャッジ時間 | 2,584 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
10,896 KB |
testcase_01 | AC | 10 ms
11,020 KB |
testcase_02 | AC | 10 ms
11,120 KB |
testcase_03 | AC | 10 ms
10,972 KB |
testcase_04 | AC | 49 ms
11,300 KB |
testcase_05 | AC | 47 ms
12,024 KB |
testcase_06 | AC | 73 ms
12,088 KB |
testcase_07 | AC | 57 ms
11,692 KB |
testcase_08 | AC | 39 ms
11,492 KB |
testcase_09 | AC | 22 ms
11,340 KB |
testcase_10 | AC | 72 ms
12,100 KB |
testcase_11 | AC | 15 ms
11,380 KB |
testcase_12 | AC | 33 ms
11,812 KB |
testcase_13 | AC | 75 ms
11,956 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; }