結果
| 問題 | No.60 魔法少女 |
| コンテスト | |
| ユーザー |
けーむ
|
| 提出日時 | 2020-08-13 14:43:53 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,989 bytes |
| 記録 | |
| コンパイル時間 | 1,669 ms |
| コンパイル使用メモリ | 172,644 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-10-09 19:11:48 |
| 合計ジャッジ時間 | 3,881 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | WA * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<typename T>
struct Imos2D {
private:
int w, h;
vector<vector<T>> dp;
public:
Imos2D(int _w, int _h) : w(_w), h(_h), dp(_w + 1, vector<T>(_h + 1, 0)) {}
void add(int ax, int ay, int bx, int by, T val) {
dp[min(w, max(0, ax))][min(h, max(0, ay))] += val;
dp[min(w, max(0, ax))][min(h, max(0, by))] -= val;
dp[min(w, max(0, bx))][min(h, max(0, ay))] -= val;
dp[min(w, max(0, bx))][min(h, max(0, by))] += val;
}
void build() {
for(int x = 1; x < w; x++) {
for(int y = 1; y < h; y++) {
dp[x][y] = dp[x][y] + dp[x - 1][y] + dp[x][y - 1] - dp[x - 1][y - 1];
}
}
}
T query(int x, int y) {
return dp[x][y];
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// ifstream in("input.txt");
// cin.rdbuf(in.rdbuf());
ll n, k;
cin >> n >> k;
Imos2D<ll> imos(1001, 1001);
rep(i, n) {
ll x, y, hp;
cin >> x >> y >> hp;
x += 500; y += 500;
imos.add(x, y, x + 1, y + 1, hp);
}
rep(i, k) {
ll ax, ay, w, h, d;
cin >> ax >> ay >> w >> h >> d;
ax += 500; ay += 500;
imos.add(ax, ay, ax + w + 1, ay + h + 1, -d);
}
imos.build();
ll ans = 0;
rep(i, 1001) {
rep(j, 1001) {
ll val = imos.query(i, j);
if (val > 0) {
ans += val;
}
}
}
cout << ans << endl;
return 0;
}
けーむ