結果

問題 No.60 魔法少女
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-04-17 19:15:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 1,367 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 171,172 KB
実行使用メモリ 10,084 KB
最終ジャッジ日時 2024-04-19 07:17:36
合計ジャッジ時間 3,046 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
8,960 KB
testcase_01 AC 9 ms
8,960 KB
testcase_02 AC 9 ms
8,960 KB
testcase_03 AC 8 ms
8,960 KB
testcase_04 AC 47 ms
9,216 KB
testcase_05 AC 51 ms
10,084 KB
testcase_06 AC 77 ms
10,084 KB
testcase_07 AC 60 ms
9,696 KB
testcase_08 AC 41 ms
9,568 KB
testcase_09 AC 23 ms
9,216 KB
testcase_10 AC 76 ms
10,084 KB
testcase_11 AC 16 ms
9,088 KB
testcase_12 AC 38 ms
9,700 KB
testcase_13 AC 86 ms
10,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

const int OFFSET = 600;
const int SIZE = 2 * OFFSET + 1;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

	int N, K;
	cin >> N >> K;

	vector<P> points;
	vector<int> hp;
	rep(i, N) {
		int x, y, c;
		cin >> x >> y >> c;
		points.emplace_back(P(x, y));
		hp.emplace_back(c);
	}

	vector<vector<int>> damage(SIZE, vector<int>(SIZE, 0));
	rep(i, K) {
		int x1, y1, w, h, d;
		cin >> x1 >> y1 >> w >> h >> d;

		int x2 = min(x1 + w, 500) + 1, y2 = min(y1 + h, 500) + 1;
		x1 += OFFSET; y1 += OFFSET; x2 += OFFSET; y2 += OFFSET;

		damage[x1][y2] -= d;	damage[x2][y2] += d;
		damage[x1][y1] += d;	damage[x2][y1] -= d;
	}

	rep(i, SIZE) {
		rep(j, SIZE - 1) {
			damage[i][j + 1] += damage[i][j];
		}
	}

	rep(j, SIZE) {
		rep(i, SIZE - 1) {
			damage[i + 1][j] += damage[i][j];
		}
	}

	int ans = 0;
	rep(i, N) {
		int x = points[i].first, y = points[i].second;
		x += OFFSET, y += OFFSET;
		ans += max(hp[i] - damage[x][y], 0);
	}

	cout << ans << endl;

}
0