結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー chocoruskchocorusk
提出日時 2020-02-01 17:31:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 4,000 ms
コード長 1,519 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 114,024 KB
実行使用メモリ 12,608 KB
最終ジャッジ日時 2023-08-16 03:11:03
合計ジャッジ時間 3,378 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,056 KB
testcase_01 AC 2 ms
8,748 KB
testcase_02 AC 3 ms
8,108 KB
testcase_03 AC 3 ms
8,356 KB
testcase_04 AC 3 ms
8,492 KB
testcase_05 AC 3 ms
8,108 KB
testcase_06 AC 3 ms
8,132 KB
testcase_07 AC 3 ms
8,324 KB
testcase_08 AC 3 ms
8,624 KB
testcase_09 AC 3 ms
8,176 KB
testcase_10 AC 3 ms
8,056 KB
testcase_11 AC 3 ms
8,408 KB
testcase_12 AC 3 ms
8,332 KB
testcase_13 AC 3 ms
8,052 KB
testcase_14 AC 2 ms
8,120 KB
testcase_15 AC 3 ms
8,188 KB
testcase_16 AC 2 ms
8,160 KB
testcase_17 AC 4 ms
8,056 KB
testcase_18 AC 3 ms
8,420 KB
testcase_19 AC 3 ms
8,384 KB
testcase_20 AC 2 ms
8,048 KB
testcase_21 AC 4 ms
8,144 KB
testcase_22 AC 4 ms
8,088 KB
testcase_23 AC 3 ms
8,144 KB
testcase_24 AC 3 ms
8,052 KB
testcase_25 AC 3 ms
8,180 KB
testcase_26 AC 3 ms
8,216 KB
testcase_27 AC 3 ms
8,236 KB
testcase_28 AC 4 ms
8,404 KB
testcase_29 AC 119 ms
12,548 KB
testcase_30 AC 97 ms
11,956 KB
testcase_31 AC 94 ms
11,740 KB
testcase_32 AC 108 ms
10,404 KB
testcase_33 AC 97 ms
11,160 KB
testcase_34 AC 88 ms
10,968 KB
testcase_35 AC 126 ms
12,608 KB
testcase_36 AC 124 ms
12,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T>
struct BIT{ //1-indexed
    vector<T> bit;
    int size;
    BIT(int n):size(n), bit(n+1, 0){}
    T sum(int i){
        T s=0;
        while(i>0){
            s+=bit[i];
            i-=(i&(-i));
        }
        return s;
    }
    void add(int i, T x){
        while(i<=size){
            bit[i]+=x;
            i+=(i&(-i));
        }
    }
};
int main()
{
	int n, w;
	ll h;
	cin>>n>>w>>h;
	vector<int> vl[100010], vr[100010];
	ll b[100010];
	for(int i=0; i<n; i++){
		int a, x;
		cin>>a>>b[i]>>x;
		vl[x].push_back(i);
		vr[a+x].push_back(i);
	}
	BIT<ll> bit(n+1);
	int c[2]={};
	for(int i=1; i<=w; i++){
		for(auto j:vl[i]){
			bit.add(j+1, b[j]);
		}
		for(auto j:vr[i]){
			bit.add(j+1, -b[j]);
		}
		int l=-1, r=n+1;
		while(r-l>1){
			int m=(l+r)/2;
			if(bit.sum(m+1)>=h) r=m;
			else l=m;
		}
		c[r&1]++;
	}
	//cerr<<c[0]<<" "<<c[1]<<endl;
	if(c[0]>c[1]) cout<<"A"<<endl;
	else if(c[0]<c[1]) cout<<"B"<<endl;
	else cout<<"DRAW"<<endl;
	return 0;
}
0