結果

問題 No.60 魔法少女
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-29 22:15:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 1,087 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 67,944 KB
実行使用メモリ 8,796 KB
最終ジャッジ日時 2023-08-13 14:58:47
合計ジャッジ時間 3,498 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,540 KB
testcase_01 AC 2 ms
5,732 KB
testcase_02 AC 2 ms
5,524 KB
testcase_03 AC 2 ms
5,708 KB
testcase_04 AC 96 ms
7,824 KB
testcase_05 AC 97 ms
8,572 KB
testcase_06 AC 163 ms
8,540 KB
testcase_07 AC 118 ms
8,284 KB
testcase_08 AC 75 ms
8,332 KB
testcase_09 AC 34 ms
7,704 KB
testcase_10 AC 154 ms
8,796 KB
testcase_11 AC 18 ms
7,180 KB
testcase_12 AC 68 ms
8,260 KB
testcase_13 AC 168 ms
8,616 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;

//2次元BIT
const int MAX_W = 1010, MAX_H = 1010;
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] += 501; y[i] += 501;// -500を1に1index
	}
	rep(i, k){
		int ax, ay, w, h, d;
		cin >> ax >> ay >> w >> h >> d;
		ax += 501; ay += 501;
		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