結果

問題 No.60 魔法少女
ユーザー fiordfiord
提出日時 2015-08-03 00:17:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 188 ms / 5,000 ms
コード長 650 bytes
コンパイル時間 1,146 ms
コンパイル使用メモリ 145,032 KB
実行使用メモリ 13,404 KB
最終ジャッジ日時 2023-09-25 00:40:15
合計ジャッジ時間 3,410 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
12,312 KB
testcase_01 AC 12 ms
12,148 KB
testcase_02 AC 11 ms
12,132 KB
testcase_03 AC 12 ms
12,164 KB
testcase_04 AC 107 ms
12,424 KB
testcase_05 AC 111 ms
13,364 KB
testcase_06 AC 181 ms
13,240 KB
testcase_07 AC 136 ms
13,024 KB
testcase_08 AC 89 ms
12,808 KB
testcase_09 AC 45 ms
12,384 KB
testcase_10 AC 171 ms
13,268 KB
testcase_11 AC 27 ms
12,424 KB
testcase_12 AC 80 ms
12,992 KB
testcase_13 AC 188 ms
13,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int maps[1501][1501];
int main(){
	int n,k;	cin>>n>>k;
	int x[n],y[n],hp[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>hp[i];
		x[i]+=500;	y[i]+=500;
	}
	int ax,ay,w,h,d;
	for(int i=0;i<k;i++){
		cin>>ax>>ay>>w>>h>>d;
		ax+=500;	ay+=500;
		maps[ax][ay]+=d;
		maps[ax+w+1][ay]-=d;	maps[ax][ay+h+1]-=d;
		maps[ax+w+1][ay+h+1]+=d;
	}
	for(int i=0;i<=1500;i++){
		for(int j=1;j<=1500;j++)	maps[i][j]+=maps[i][j-1];
	}
	for(int i=1;i<=1500;i++){
		for(int j=0;j<=1500;j++)	maps[i][j]+=maps[i-1][j];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=max(0,hp[i]-maps[x[i]][y[i]]);
	}
	cout<<ans<<endl;
	return 0;
}
0