結果

問題 No.60 魔法少女
ユーザー myantamyanta
提出日時 2017-05-11 04:31:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 1,071 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 46,408 KB
実行使用メモリ 7,656 KB
最終ジャッジ日時 2023-10-13 10:29:04
合計ジャッジ時間 1,942 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,984 KB
testcase_01 AC 9 ms
6,968 KB
testcase_02 AC 8 ms
6,932 KB
testcase_03 AC 9 ms
6,936 KB
testcase_04 AC 50 ms
6,888 KB
testcase_05 AC 50 ms
7,648 KB
testcase_06 AC 80 ms
7,656 KB
testcase_07 AC 61 ms
7,324 KB
testcase_08 AC 43 ms
7,104 KB
testcase_09 AC 24 ms
6,928 KB
testcase_10 AC 77 ms
7,560 KB
testcase_11 AC 15 ms
6,976 KB
testcase_12 AC 37 ms
7,328 KB
testcase_13 AC 82 ms
7,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<vector>


using namespace std;


struct enemy_t
{
	int x, y, hp;
};

vector<enemy_t> ene;


int main(void)
{
	int i, n, k;
	int x, y, w, h, d;
	int ans;
	vector<vector<int> > f;

	while(scanf("%d%d", &n, &k)==2)
	{
		f.clear();
		f.resize(1001);
		for(auto& fe: f) fe.resize(1001);

		ene.resize(n);
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d", &x, &y, &ene[i].hp);
			ene[i].x=x+500;
			ene[i].y=y+500;
		}

		for(i=0;i<k;i++)
		{
			scanf("%d%d%d%d%d", &x, &y, &w, &h, &d);
			x+=500;
			y+=500;
			f[y][x]+=d;
			if(x+w+1<=1000)                f[y    ][x+w+1]-=d;
			if(y+h+1<=1000)                f[y+h+1][x    ]-=d;
			if(x+w+1<=1000 && y+h+1<=1000) f[y+h+1][x+w+1]+=d;
		}

		for(y=0;y<=1000;y++)
		{
			for(x=1;x<=1000;x++)
			{
				f[y][x]+=f[y][x-1];
			}
		}
		for(y=1;y<=1000;y++)
		{
			for(x=0;x<=1000;x++)
			{
				f[y][x]+=f[y-1][x];
			}
		}

		ans=0;
		for(i=0;i<n;i++)
		{
			enemy_t& t=ene[i];
			ans+=max(0, t.hp-f[t.y][t.x]);
		}
/*
for(auto t: ene) printf("%d ", t.hp);
printf("\n");
*/
		printf("%d\n", ans);
	}
	return 0;
}
0