結果
問題 |
No.60 魔法少女
|
ユーザー |
![]() |
提出日時 | 2020-09-06 16:16:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 99 ms / 5,000 ms |
コード長 | 952 bytes |
コンパイル時間 | 2,180 ms |
コンパイル使用メモリ | 203,380 KB |
最終ジャッジ日時 | 2025-01-14 07:51:30 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, K; cin >> N >> K; vector<tuple<int, int, int>> V(N); for (int i = 0; i < N; i++) { int x, y, hp; cin >> x >> y >> hp; V.at(i) = {x + 500, y + 500, hp}; } N = 1502; vector DP(N, vector(N, 0)); for (int i = 0; i < K; i++) { int x, y, w, h, d; cin >> x >> y >> w >> h >> d; x += 500, y += 500; DP.at(x).at(y) += d; DP.at(x + w + 1).at(y) -= d; DP.at(x).at(y + h + 1) -= d; DP.at(x + w + 1).at(y + h + 1) += d; } for (int i = 0; i < N; i++) { for (int j = 0; j + 1 < N; j++) { DP.at(i).at(j + 1) += DP.at(i).at(j); } } for (int i = 0; i + 1 < N; i++) { for (int j = 0; j < N; j++) { DP.at(i + 1).at(j) += DP.at(i).at(j); } } long ans = 0; for (auto [x, y, hp] : V) { ans += max(0, hp - DP.at(x).at(y)); } cout << ans << "\n"; }