結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
18,816 KB
testcase_01 AC 25 ms
18,944 KB
testcase_02 AC 25 ms
18,944 KB
testcase_03 AC 25 ms
18,816 KB
testcase_04 AC 68 ms
19,072 KB
testcase_05 AC 70 ms
20,096 KB
testcase_06 AC 101 ms
19,968 KB
testcase_07 AC 81 ms
19,584 KB
testcase_08 AC 60 ms
19,456 KB
testcase_09 AC 40 ms
19,200 KB
testcase_10 AC 96 ms
20,096 KB
testcase_11 AC 32 ms
19,072 KB
testcase_12 AC 54 ms
19,584 KB
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

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 = 1000;
	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