結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  Ysmr_Ry | 
| 提出日時 | 2014-11-10 21:33:29 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 87 ms / 5,000 ms | 
| コード長 | 1,062 bytes | 
| コンパイル時間 | 513 ms | 
| コンパイル使用メモリ | 38,400 KB | 
| 実行使用メモリ | 7,972 KB | 
| 最終ジャッジ日時 | 2024-12-31 09:28:25 | 
| 合計ジャッジ時間 | 1,953 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         scanf( "%d%d", &N, &K );
      |         ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf( "%d%d%d", &x, &y, &hp );
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |                 scanf( "%d%d%d%d%d", &ax, &ay, &w, &h, &d );
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include<cstdio>
#include<numeric>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)
struct dat
{ 
	int x, y, hp; 
	dat( int x, int y, int hp )
	:	x(x), y(y), hp(hp)
	{}
};
int N, K;
int fld[1002][1002];
std::vector<dat> pts;
int main()
{
	scanf( "%d%d", &N, &K );
	rep( i, N )
	{
		int x, y, hp;
		scanf( "%d%d%d", &x, &y, &hp );
		pts.push_back( dat( x, y, hp ) );
	}
	rep( i, K )
	{
		int ax, ay, w, h, d;
		scanf( "%d%d%d%d%d", &ax, &ay, &w, &h, &d );
		ax += 500, ay += 500;
		fld[ay][ax] -= d; 
		if( ax+w+1 <= 1000 ) fld[ay][ax+w+1] += d;
		if( ay+h+1 <= 1000 ) fld[ay+h+1][ax] += d;
		if( ax+w+1 <= 1000 && ay+h+1 <= 1000 ) fld[ay+h+1][ax+w+1] -= d;
	}
	rep( i, 1002 )
		std::partial_sum( fld[i], fld[i]+1002, fld[i] );
	rep( j, 1002 ) rep( i, 1001 )
		fld[i+1][j] += fld[i][j];
	int ans = 0;
	rep( i, N )
	{
		fld[pts[i].y+500][pts[i].x+500] += pts[i].hp;
		if( fld[pts[i].y+500][pts[i].x+500] > 0 )
			ans += fld[pts[i].y+500][pts[i].x+500];
	}
	printf( "%d\n", ans );
	return 0;
}
            
            
            
        