結果

問題 No.60 魔法少女
ユーザー cielciel
提出日時 2015-04-24 03:46:01
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 24,672 KB
実行使用メモリ 9,712 KB
最終ジャッジ日時 2023-09-18 08:51:37
合計ジャッジ時間 3,420 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,768 KB
testcase_01 AC 7 ms
5,720 KB
testcase_02 AC 7 ms
5,732 KB
testcase_03 AC 8 ms
7,704 KB
testcase_04 AC 51 ms
9,624 KB
testcase_05 AC 59 ms
9,652 KB
testcase_06 AC 90 ms
9,680 KB
testcase_07 AC 67 ms
9,600 KB
testcase_08 AC 46 ms
9,712 KB
testcase_09 AC 24 ms
9,676 KB
testcase_10 AC 86 ms
9,556 KB
testcase_11 AC 16 ms
9,628 KB
testcase_12 AC 42 ms
9,676 KB
testcase_13 AC 92 ms
9,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int field[1001][1001];
int damage[1002][1002];
int main(){
	int N,K,i,j,R=0;
	scanf("%d%d",&N,&K);
	for(i=0;i<N;i++){
		int x,y,h;
		scanf("%d%d%d",&x,&y,&h);
		field[y+500][x+500]=h;
	}
	for(i=0;i<K;i++){
		int x,y,w,h,d;
		scanf("%d%d%d%d%d",&x,&y,&w,&h,&d);
		x+=500,y+=500;
		int xe=x+w+1,ye=y+h+1;
		if(xe>1001)xe=1001;
		if(ye>1001)ye=1001;
		damage[y][x]+=d;
		damage[y][xe]-=d;
		damage[ye][x]-=d;
		damage[ye][xe]+=d;
	}
	for(i=0;i<1001;i++)for(j=1;j<1001;j++)damage[i][j]+=damage[i][j-1];
	for(i=1;i<1001;i++)for(j=0;j<1001;j++)damage[i][j]+=damage[i-1][j];
	for(i=0;i<1001;i++)for(j=0;j<1001;j++)if(field[i][j]>damage[i][j])R+=field[i][j]-damage[i][j];
	printf("%d\n",R);
	return 0;
}
0