結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー tansunogontansunogon
提出日時 2017-05-09 06:48:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,754 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 78,144 KB
実行使用メモリ 9,720 KB
最終ジャッジ日時 2023-10-12 20:12:48
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,356 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,352 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 AC 2 ms
4,352 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 58 ms
9,656 KB
testcase_30 AC 46 ms
9,192 KB
testcase_31 AC 42 ms
8,524 KB
testcase_32 AC 34 ms
8,080 KB
testcase_33 AC 40 ms
6,524 KB
testcase_34 AC 33 ms
6,200 KB
testcase_35 AC 56 ms
9,720 KB
testcase_36 AC 56 ms
9,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct iostream_init_struct
{ 
	iostream_init_struct()
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}
} iostream_init;

// index begins with 1
class BIT
{
public:
	vector<long long> data;
	const int msb_n;

	BIT(int n) : data(n + 1), msb_n(1 << log(n)) {}

	void add(int i, int v)
	{
		for (int x = i; x < data.size(); x += x & -x)
		{
			data[x] += v;
		}
	}

	//long long sum(int i)
	//{
	//	int ret = 0;
	//	for (int x = i; x > 0; x -= x & -x)
	//	{
	//		ret += data[x];
	//	}
	//	return ret;
	//}

	int lowerBound(long long v)
	{
		int x = 0;
		for (int k = msb_n; k > 0; k /= 2)
		{
			if (x + k < data.size() && data[x + k] < v)
			{
				v -= data[x + k];
				x += k;
			}
		}
		return x + 1;
	}

	inline static int log(int n)
	{
#ifdef __GNUC__
		return std::__lg(n);
#else
		int ret = 0;
		while (n = n >> 1)
		{
			ret += 1;
		}
		return ret;
#endif
	}
};

int n;
long long h;
int w;

// adding_data[i][]
//        i: place
//    first: time
//   second: b (height)
vector<vector<pair<int, int>>> adding_data;

int main()
{
	cin >> n >> w >> h;
	adding_data = vector<vector<pair<int, int>>>(w + 2);
	for (int i = 1; i <= n; ++i)
	{
		int a, b, x;
		cin >> a >> b >> x;
		adding_data[x].emplace_back(i, b);
		adding_data[x + a].emplace_back(i, -b);
	}

	BIT bit(w);

	int A_score = 0;
	for (int x = 1; x <= w; ++x)
	{
		for (auto data : adding_data[x])
		{
			int time = data.first;
			int add_height = data.second;
			bit.add(time, add_height);
		}
		A_score += bit.lowerBound(h) & 1;
	}

	int B_score = w - A_score;

	if (A_score > B_score)
		cout << "A" << endl;
	else if (A_score < B_score)
		cout << "B" << endl;
	else
		cout << "DRAW" << endl;
}
0