結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
ninoinui
|
| 提出日時 | 2020-09-06 16:20:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 5,000 ms |
| コード長 | 996 bytes |
| コンパイル時間 | 2,145 ms |
| コンパイル使用メモリ | 201,788 KB |
| 最終ジャッジ日時 | 2025-01-14 07:51:53 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = 1002;
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(min(1000, x + w) + 1).at(y) -= d;
DP.at(x).at(min(1000, y + h) + 1) -= d;
DP.at(min(1000, x + w) + 1).at(min(1000, 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";
}
ninoinui