結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  myanta | 
| 提出日時 | 2017-05-11 04:31:10 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 84 ms / 5,000 ms | 
| コード長 | 1,071 bytes | 
| コンパイル時間 | 422 ms | 
| コンパイル使用メモリ | 44,288 KB | 
| 実行使用メモリ | 7,936 KB | 
| 最終ジャッジ日時 | 2024-09-15 07:34:08 | 
| 合計ジャッジ時間 | 1,847 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |                         scanf("%d%d%d", &x, &y, &ene[i].hp);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:39:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |                         scanf("%d%d%d%d%d", &x, &y, &w, &h, &d);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#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;
}
            
            
            
        