結果

問題 No.60 魔法少女
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-30 15:45:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 208 ms / 5,000 ms
コード長 1,009 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 66,636 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-05-01 08:14:57
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
12,672 KB
testcase_01 AC 9 ms
12,516 KB
testcase_02 AC 9 ms
12,584 KB
testcase_03 AC 9 ms
12,504 KB
testcase_04 AC 118 ms
12,672 KB
testcase_05 AC 121 ms
13,568 KB
testcase_06 AC 204 ms
13,568 KB
testcase_07 AC 149 ms
13,144 KB
testcase_08 AC 97 ms
13,184 KB
testcase_09 AC 48 ms
12,800 KB
testcase_10 AC 190 ms
13,568 KB
testcase_11 AC 27 ms
12,800 KB
testcase_12 AC 86 ms
13,312 KB
testcase_13 AC 208 ms
13,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int n, k;
int x[100010], y[100010], hp[100010];
int imos[1510][1510];

//imos
int main(void){
	cin >> n >> k;
	rep(i, n){
		cin >> x[i] >> y[i] >> hp[i];
		x[i] += 500; y[i] += 500;
	}

	rep(i, 1510)rep(j, 1510) imos[i][j] = 0;

	rep(i, k){
		int ax, ay, w, h, d;
		cin >> ax >> ay >> w >> h >> d;
		ax += 500; ay += 500;
		imos[ay][ax] += d;//左上
		imos[ay][ax + w + 1] -= d;//右上
		imos[ay + h + 1][ax] -= d;//左下
		imos[ay + h + 1][ax + w + 1] += d;//右下
	}

	//横方向への累積和
	rep(i, 1505)rep(j, 1505){
		imos[i][j + 1] += imos[i][j];
	}
	//縦方向の累積和
	rep(i, 1505)rep(j, 1505){
		imos[i + 1][j] += imos[i][j];
	}

	ll ans = 0;
	rep(i, n){
		int ty = y[i], tx = x[i];
		ans += max((ll)0, (ll)(hp[i] - imos[ty][tx]));
	}
	printf("%lld\n", ans);
	return 0;
}
0