結果

問題 No.60 魔法少女
ユーザー pekempeypekempey
提出日時 2015-08-19 15:58:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 241 ms / 5,000 ms
コード長 1,008 bytes
コンパイル時間 1,217 ms
コンパイル使用メモリ 144,448 KB
実行使用メモリ 36,436 KB
最終ジャッジ日時 2023-09-25 13:19:12
合計ジャッジ時間 4,404 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
36,148 KB
testcase_01 AC 85 ms
36,156 KB
testcase_02 AC 86 ms
36,140 KB
testcase_03 AC 70 ms
36,224 KB
testcase_04 AC 159 ms
36,164 KB
testcase_05 AC 164 ms
36,436 KB
testcase_06 AC 235 ms
36,376 KB
testcase_07 AC 189 ms
36,152 KB
testcase_08 AC 142 ms
35,980 KB
testcase_09 AC 96 ms
35,464 KB
testcase_10 AC 222 ms
36,316 KB
testcase_11 AC 78 ms
35,548 KB
testcase_12 AC 131 ms
36,132 KB
testcase_13 AC 241 ms
36,436 KB
権限があれば一括ダウンロードができます

ソースコード

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