結果

問題 No.60 魔法少女
ユーザー data9824data9824
提出日時 2015-06-18 01:38:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 251 ms / 5,000 ms
コード長 1,000 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 63,776 KB
実行使用メモリ 10,124 KB
最終ジャッジ日時 2023-09-21 09:25:06
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,320 KB
testcase_01 AC 6 ms
7,304 KB
testcase_02 AC 5 ms
7,364 KB
testcase_03 AC 5 ms
7,332 KB
testcase_04 AC 151 ms
8,548 KB
testcase_05 AC 131 ms
8,788 KB
testcase_06 AC 241 ms
9,956 KB
testcase_07 AC 176 ms
9,072 KB
testcase_08 AC 109 ms
8,676 KB
testcase_09 AC 51 ms
7,884 KB
testcase_10 AC 223 ms
9,952 KB
testcase_11 AC 22 ms
7,884 KB
testcase_12 AC 89 ms
8,364 KB
testcase_13 AC 251 ms
10,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n), y(n), hp(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i] >> hp[i];
	}
	vector<int> ax(k), ay(k), w(k), h(k), d(k);
	for (int i = 0; i < k; ++i) {
		cin >> ax[i] >> ay[i] >> w[i] >> h[i] >> d[i];
	}
	vector<vector<int> > offset(1001 + 1, vector<int>(1001));
	for (int i = 0; i < n; ++i) {
		offset[x[i] + 500][y[i] + 500] += hp[i];
		offset[x[i] + 500 + 1][y[i] + 500] -= hp[i];
	}
	for (int i = 0; i < k; ++i) {
		for (int y = ay[i]; y <= ay[i] + h[i]; ++y) {
			if (y + 500 < 1001) {
				offset[ax[i] + 500][y + 500] -= d[i];
				if (ax[i] + w[i] + 1 + 500 < 1001 + 1) {
					offset[ax[i] + w[i] + 1 + 500][y + 500] += d[i];
				}
			}
		}
	}
	int hpSum = 0;
	for (int y = 0; y <= 1000; ++y) {
		int current = 0;
		for (int x = 0; x <= 1000; ++x) {
			current += offset[x][y];
			if (current > 0) {
				hpSum += current;
			}
		}
	}
	cout << hpSum << endl;
	return 0;
}
0