結果

問題 No.60 魔法少女
ユーザー pekempey
提出日時 2015-08-19 15:58:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 210 ms / 5,000 ms
コード長 1,008 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 159,496 KB
実行使用メモリ 36,480 KB
最終ジャッジ日時 2024-07-18 10:30:38
合計ジャッジ時間 3,794 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

int N, K;
int X[100000], Y[100000], HP[100000];
const int offset = 1010;
ll imos[2020][2020];

int main() {
	cin >> N >> K;
	rep (i, N) {
		cin >> X[i] >> Y[i] >> HP[i];
		X[i] += offset;
		Y[i] += offset;
	}
	rep (i, K) {
		int x, y, w, h, d;
		cin >> x >> y >> w >> h >> d;
		x += offset;
		y += offset;

		imos[y][x] += d;
		imos[y + h + 1][x] -= d;
		imos[y][x + w + 1] -= d;
		imos[y + h + 1][x + w + 1] += d;
	}

	rep (i, 2020) {
		rep (j, 2020 - 1) {
			imos[i][j + 1] += imos[i][j];
		}
	}

	rep (j, 2020) {
		rep (i, 2020 - 1) {
			imos[i + 1][j] += imos[i][j];
		}
	}

	ll ans = 0;
	rep (i, N) {
		ans += max<ll>(0, HP[i] - imos[Y[i]][X[i]]);
	}
	cout << ans << endl;
}
0