結果

問題 No.60 魔法少女
ユーザー hotpepsihotpepsi
提出日時 2020-04-19 12:35:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 200 ms / 5,000 ms
コード長 1,156 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 78,388 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-04-15 09:19:01
合計ジャッジ時間 3,837 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
11,264 KB
testcase_01 AC 10 ms
11,136 KB
testcase_02 AC 11 ms
11,264 KB
testcase_03 AC 10 ms
11,136 KB
testcase_04 AC 109 ms
12,800 KB
testcase_05 AC 121 ms
12,928 KB
testcase_06 AC 194 ms
14,080 KB
testcase_07 AC 146 ms
13,440 KB
testcase_08 AC 94 ms
12,672 KB
testcase_09 AC 46 ms
11,648 KB
testcase_10 AC 180 ms
13,952 KB
testcase_11 AC 28 ms
11,392 KB
testcase_12 AC 86 ms
12,288 KB
testcase_13 AC 200 ms
14,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	int n, k;
	cin >> n >> k;
	vector<int> ex(n), ey(n), ehp(n), ax(k), ay(k), aw(k), ah(k), ad(k);
	for (int i = 0; i < n; ++i) {
		cin >> ex[i] >> ey[i] >> ehp[i];
		ex[i] += 500;
		ey[i] += 500;
	}
	for (int i = 0; i < k; ++i) {
		cin >> ax[i] >> ay[i] >> aw[i] >> ah[i] >> ad[i];
		ax[i] += 500;
		ay[i] += 500;
	}
	vector<vector<LL>> sum(1002, vector<LL>(1002));
	for (int i = 0; i < k; ++i) {
		int left = ax[i], right = min(1000, ax[i] + aw[i]) + 1;
		int top = ay[i], bottom = min(1000, ay[i] + ah[i]) + 1;
		sum[top][left] += ad[i];
		sum[top][right] -= ad[i];
		sum[bottom][left] -= ad[i];
		sum[bottom][right] += ad[i];
	}
	for (int y = 0; y <= 1001; ++y) {
		for (int x = 1; x <= 1001; ++x) {
			sum[y][x] += sum[y][x - 1];
		}
	}
	for (int y = 1; y <= 1001; ++y) {
		for (int x = 0; x <= 1001; ++x) {
			sum[y][x] += sum[y - 1][x];
		}
	}
	LL ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += max(0LL, ehp[i] - sum[ey[i]][ex[i]]);
	}
	cout << ans << endl;
	return 0;
}
0