結果

問題 No.60 魔法少女
コンテスト
ユーザー myanta
提出日時 2017-05-11 04:13:52
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,090 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 447 ms
コンパイル使用メモリ 63,872 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2026-04-04 18:17:13
合計ジャッジ時間 1,606 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<cstdio>
#include<vector>


using namespace std;


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

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;
			ene[i].f=-1;
		}

		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