結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー SSRSSSRS
提出日時 2021-12-18 18:01:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 120 ms / 4,000 ms
コード長 1,331 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 174,352 KB
実行使用メモリ 12,680 KB
最終ジャッジ日時 2023-08-16 03:11:42
合計ジャッジ時間 3,786 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 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,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 120 ms
12,556 KB
testcase_30 AC 98 ms
11,184 KB
testcase_31 AC 87 ms
10,508 KB
testcase_32 AC 112 ms
10,488 KB
testcase_33 AC 87 ms
10,828 KB
testcase_34 AC 83 ms
10,448 KB
testcase_35 AC 117 ms
12,680 KB
testcase_36 AC 119 ms
12,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
struct binary_indexed_tree{
  int N;
  vector<long long> BIT;
  binary_indexed_tree(int N): N(N), BIT(N + 1, 0){
  }
  void add(int i, long long x){
    i++;
    while (i <= N){
      BIT[i] += x;
      i += i & -i;
    }
  }
  long long sum(int i){
    long long ans = 0;
    while (i > 0){
      ans += BIT[i];
      i -= i & -i;
    }
    return ans;
  }
};
int main(){
  int n, w;
  long long h;
  cin >> n >> w >> h;
  vector<int> a(n), b(n), x(n);
  for (int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> x[i];
    x[i]--;
  }
  vector<vector<pair<int, long long>>> add(w + 1);
  for (int i = 0; i < n; i++){
    add[x[i]].push_back(make_pair(i, b[i]));
    add[x[i] + a[i]].push_back(make_pair(i, -b[i]));
  }
  long long A = 0, B = 0;
  binary_indexed_tree BIT(n);
  for (int i = 0; i < w; i++){
    for (auto P : add[i]){
      BIT.add(P.first, P.second);
    }
    int tv = n + 1, fv = 0;
    while (tv - fv > 1){
      int mid = (tv + fv) / 2;
      if (BIT.sum(mid) >= h){
        tv = mid;
      } else {
        fv = mid;
      }
    }
    if (tv != n + 1){
      if (tv % 2 == 1){
        A++;
      } else {
        B++;
      }
    }
  }
  if (A > B){
    cout << 'A' << endl;
  } else if (A < B){
    cout << 'B' << endl;
  } else {
    cout << "DRAW" << endl;
  }
}
0