結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-28 23:34:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 5,000 ms |
| コード長 | 926 bytes |
| コンパイル時間 | 1,606 ms |
| コンパイル使用メモリ | 174,892 KB |
| 実行使用メモリ | 13,696 KB |
| 最終ジャッジ日時 | 2024-06-12 00:40:33 |
| 合計ジャッジ時間 | 4,204 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int imos[1010][1010];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, K;
cin >> N >> K;
map<P, int> m;
for (int i = 0; i < N; i++) {
int x, y, hp;
cin >> x >> y >> hp;
x += 500;
y += 500;
m[P(x, y)] = hp;
}
for (int i = 0; i < K; i++) {
int x, y, w, h, d;
cin >> x >> y >> w >> h >> d;
x += 500;
y += 500;
int nx = min(x + w + 1, 1001), ny = min(y + h + 1, 1001);
imos[x][y] += d;
imos[nx][y] -= d;
imos[x][ny] -= d;
imos[nx][ny] += d;
}
for (int i = 0; i <= 1000; i++) {
for (int j = 1; j <= 1000; j++) {
imos[i][j] += imos[i][j - 1];
}
}
for (int i = 1; i <= 1000; i++) {
for (int j = 0; j <= 1000; j++) {
imos[i][j] += imos[i - 1][j];
}
}
int ans = 0;
for (auto p : m) {
ans += max(p.second - imos[p.first.first][p.first.second], 0);
}
cout << ans << endl;
return 0;
}