結果

問題 No.60 魔法少女
ユーザー bal4ubal4u
提出日時 2019-06-19 20:38:02
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,143 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 29,612 KB
実行使用メモリ 6,884 KB
最終ジャッジ日時 2023-08-20 07:17:11
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,836 KB
testcase_01 AC 5 ms
5,816 KB
testcase_02 AC 5 ms
5,864 KB
testcase_03 AC 5 ms
5,864 KB
testcase_04 AC 14 ms
5,968 KB
testcase_05 AC 16 ms
6,816 KB
testcase_06 AC 26 ms
6,816 KB
testcase_07 AC 19 ms
6,528 KB
testcase_08 AC 14 ms
6,360 KB
testcase_09 AC 7 ms
5,992 KB
testcase_10 AC 23 ms
6,884 KB
testcase_11 AC 7 ms
6,020 KB
testcase_12 AC 12 ms
6,472 KB
testcase_13 AC 25 ms
6,868 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:7:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    7 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:13:24: 備考: in expansion of macro ‘gc’
   13 |         int n = 0, c = gc();
      |                        ^~

ソースコード

diff #

// 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