結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー SSRSSSRS
提出日時 2021-12-18 17:55:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,876 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 170,756 KB
実行使用メモリ 7,400 KB
最終ジャッジ日時 2023-10-13 17:59:20
合計ジャッジ時間 5,195 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,356 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,352 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,352 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 3 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 3 ms
4,352 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 173 ms
7,400 KB
testcase_30 AC 144 ms
7,308 KB
testcase_31 AC 133 ms
7,332 KB
testcase_32 AC 101 ms
7,312 KB
testcase_33 WA -
testcase_34 AC 153 ms
4,348 KB
testcase_35 AC 189 ms
6,916 KB
testcase_36 AC 182 ms
7,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
struct lazy_segment_tree{
  int N;
  vector<long long> ST, lazy;
  lazy_segment_tree(int N2){
    N = 1;
    while (N < N2){
      N *= 2;
    }
    ST = vector<long long>(N * 2 - 1, 0);
    lazy = vector<long long>(N * 2 - 1, -1);
  }
  void eval(int i){
    if (lazy[i] != -1){
      if (i < N - 1){
        lazy[i * 2 + 1] = lazy[i];
        lazy[i * 2 + 2] = lazy[i];
      }
      ST[i] = lazy[i];
      lazy[i] = -1;
    }
  }
  void range_update(int L, int R, long long x, int i, int l, int r){
    eval(i);
    if (r <= L || R <= l){
      return;
    } else if (L <= l && r <= R){
      lazy[i] = x;
      eval(i);
    } else {
      int m = (l + r) / 2;
      range_update(L, R, x, i * 2 + 1, l, m);
      range_update(L, R, x, i * 2 + 2, m, r);
      ST[i] = max(ST[i * 2 + 1], ST[i * 2 + 2]);
    }
  }
  void range_update(int L, int R, long long x){
    range_update(L, R, x, 0, 0, N);
  }
  long long range_max(int L, int R, int i, int l, int r){
    eval(i);
    if (r <= L || R <= l){
      return 0;
    } else if (L <= l && r <= R){
      return ST[i];
    } else {
      int m = (l + r) / 2;
      return max(range_max(L, R, i * 2 + 1, l, m), range_max(L, R, i * 2 + 2, m, r));
    }
  }
  long long range_max(int L, int R){
    return range_max(L, R, 0, 0, N);
  }
};
int main(){
  int n, w;
  long long h;
  cin >> n >> w >> h;
  lazy_segment_tree ST(w);
  long long A = 0, B = 0;
  for (int i = 0; i < n; i++){
    int a, b, x;
    cin >> a >> b >> x;
    x--;
    long long mx = ST.range_max(x, x + a);
    if (mx < h && mx + b >= h){
      if (i % 2 == 0){
        A += a;
      }
      if (i % 2 == 1){
        B += a;
      }
    }
    ST.range_update(x, x + a, mx + b);
  }
  if (A > B){
    cout << 'A' << endl;
  } else if (A < B){
    cout << 'B' << endl;
  } else {
    cout << "DRAW" << endl;
  }
}
0