結果

問題 No.60 魔法少女
ユーザー HaarHaar
提出日時 2016-05-31 21:17:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,219 bytes
コンパイル時間 1,332 ms
コンパイル使用メモリ 164,452 KB
実行使用メモリ 39,680 KB
最終ジャッジ日時 2024-04-16 21:19:02
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
38,400 KB
testcase_01 AC 56 ms
38,400 KB
testcase_02 AC 56 ms
38,400 KB
testcase_03 AC 56 ms
38,400 KB
testcase_04 AC 100 ms
38,528 KB
testcase_05 AC 100 ms
39,680 KB
testcase_06 AC 132 ms
39,680 KB
testcase_07 AC 109 ms
39,168 KB
testcase_08 AC 90 ms
39,040 KB
testcase_09 AC 72 ms
38,656 KB
testcase_10 AC 128 ms
39,552 KB
testcase_11 AC 63 ms
38,656 KB
testcase_12 AC 86 ms
39,296 KB
testcase_13 AC 135 ms
39,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define PF push_front
#define ALL(x) (x).begin(), (x).end()
#define C complex
#define CI complex< int >
#define CD complex< double >
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	int ax, ay, w, h, d;
	const int MAX = 1500;
	vector< int > x, y, hp;
	vector< vector< int > > f;
	
	cin >> n >> k;
	
	x.RS(n);
	y.RS(n);
	hp.RS(n);
	REP(i, n){
		cin >> x[i] >> y[i] >> hp[i];
	}
	
	f.RS(2*MAX+1);
	REP(i, 2*MAX+1){
		f[i].RS(2*MAX+1);
	}
	
	
	REP(i, k){
		cin >> ax >> ay >> w >> h >> d;
		
		f[ax+MAX][ay+MAX] += d;
		f[ax+w+1+MAX][ay+MAX] -= d;
		f[ax+MAX][ay+h+1+MAX] -= d;
		f[ax+w+1+MAX][ay+h+1+MAX] += d;
	}
	
	FOR(i, 0, 2*MAX+1){
		FOR(j, 1, 2*MAX+1){
			f[i][j] += f[i][j-1];
		}
	}
	
	FOR(i, 1, 2*MAX+1){
		FOR(j, 0, 2*MAX+1){
			f[i][j] += f[i-1][j];
		}
	}
	
	REP(i, n){
		hp[i] -= f[x[i]+MAX][y[i]+MAX];
		
		if(hp[i] < 0) hp[i] = 0;
	}
	
	cout << accumulate(ALL(hp), 0) << endl;
	
	return 0;
}
0