結果

問題 No.60 魔法少女
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-29 22:06:52
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,080 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 67,292 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-05-01 07:51:15
合計ジャッジ時間 7,247 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

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;

//2次元BIT
const int MAX_W = 1000, MAX_H = 1000;
int bit[MAX_W + 1][MAX_H + 1];
void add(int a, int b, ll w){
	for (int y = a; y < MAX_W; y += y & -y){
		for (int x = b; x < MAX_H; x += x & -x){
			bit[y][x] += w;
		}
	}
}

ll sum(int a, int b){
	ll ret = 0;
	for (int y = a; y > 0; y -= y & -y){
		for (int x = b; x > 0; x -= x & -x){
			ret += bit[y][x];
		}
	}
	return ret;
}

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

int main(void){
	cin >> n >> k;
	rep(i, n){
		cin >> x[i] >> y[i] >> hp[i];
		x[i] += 500; y[i] += 500;// 0を500に
	}
	rep(i, k){
		int ax, ay, w, h, d;
		cin >> ax >> ay >> w >> h >> d;
		ax += 500; ay += 500;
		add(ay, ax, d);
		add(ay + h + 1, ax, -d);
		add(ay, ax + w + 1, -d);
		add(ay + h + 1, ax + w + 1, d);
	}

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