結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー pekempeypekempey
提出日時 2017-06-23 00:27:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 409 ms / 4,000 ms
コード長 1,296 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 70,224 KB
実行使用メモリ 116,412 KB
最終ジャッジ日時 2023-08-16 03:09:11
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,504 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 4 ms
4,780 KB
testcase_22 AC 3 ms
4,408 KB
testcase_23 AC 3 ms
4,412 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 4 ms
4,516 KB
testcase_27 AC 4 ms
4,728 KB
testcase_28 AC 4 ms
4,652 KB
testcase_29 AC 346 ms
116,412 KB
testcase_30 AC 293 ms
96,848 KB
testcase_31 AC 267 ms
91,888 KB
testcase_32 AC 230 ms
116,384 KB
testcase_33 AC 281 ms
116,376 KB
testcase_34 AC 283 ms
116,308 KB
testcase_35 AC 405 ms
116,384 KB
testcase_36 AC 409 ms
116,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

struct node {
	node *l = nullptr;
	node *r = nullptr;
	long long add = 0;
};

constexpr int N = 1 << 17;

node *update(node *x, int k, long long v, int l = 0, int r = N) {
	x = x ? new node(*x) : new node();
	x->add += v;
	if (r - l == 1) return x;
	int m = (l + r) / 2;
	if (k < m) {
		x->l = update(x->l, k, v, l, m);
	} else {
		x->r = update(x->r, k, v, m, r);
	}
	return x;
}

long long query(node *x, int k, int l = 0, int r = N) {
	if (!x) return 0;
	if (k <= l) return 0;
	if (r <= k) return x->add;
	long long vl = query(x->l, k, l, (l + r) / 2);
	long long vr = query(x->r, k, (l + r) / 2, r);
	return vl + vr;
}

int main() {
	int n, w;
	long long h;
	std::cin >> n >> w >> h;

	std::vector<node *> segs(n + 1);

	for (int i = 0; i < n; i++) {
		int a, b, x;
		scanf("%d %d %d", &a, &b, &x);
		x--;
		
		segs[i + 1] = segs[i];
		segs[i + 1] = update(segs[i + 1], x, b);
		segs[i + 1] = update(segs[i + 1], x + a, -b);
	}

	int A = 0;
	int B = 0;
	for (int i = 0; i < w; i++) {
		int ok = n;
		int ng = 0;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (query(segs[mid], i + 1) >= h) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		if (ok % 2 == 1) {
			A++;
		} else {
			B++;
		}
	}

	puts(A > B ? "A" : A < B ? "B" : "DRAW");
}
0