結果

問題 No.60 魔法少女
コンテスト
ユーザー bal4u
提出日時 2019-06-19 20:38:02
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 1,143 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 210 ms
コンパイル使用メモリ 40,680 KB
最終ジャッジ日時 2026-02-22 03:38:00
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yukicoder: No.60 魔法少女
// 2019.6.19 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力(負数対応)
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define BASE 500
int X[100005], Y[100005], HP[100005];
int map[1005][1005];

int main()
{
	int i, x, y, w, h, d, s, N, K;

	N = in(), K = in();
	for (i = 0; i < N; i++) {
		X[i] = in() + BASE;
		Y[i] = in() + BASE;
		HP[i] = in();
	}
	
	while (K--) {
		x = BASE + in(), y = BASE + in();
		w = x + in() + 1, h = y + in() + 1, d = in();
		if (w > 1001) w = 1001;
		if (h > 1001) h = 1001;
		map[y][x] += d;
		map[y][w] -= d;
		map[h][x] -= d;
		map[h][w] += d;
	}
	
	for (y = 0; y <= 1001; y++) for (x = 0; x <= 1001; x++)
		map[y][x+1] += map[y][x];
	for (y = 0; y <= 1001; y++) for (x = 0; x <= 1001; x++)
		map[y+1][x] += map[y][x];
	
	s = 0;
	for (i = 0; i < N; i++) {
		d = HP[i] - map[Y[i]][X[i]];
		if (d > 0) s += d;
	}
	printf("%d\n", s);
	return 0;
}
0