結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
コンテスト
ユーザー t98slider
提出日時 2026-11-23 02:24:49
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 68 ms / 4,000 ms
+ 868µs
コード長 2,199 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,989 ms
コンパイル使用メモリ 349,132 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-11-23 02:24:56
合計ジャッジ時間 6,333 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 区間加算・全体最大値・最大値の位置取得・一点を -inf にする遅延セグ木
// (まだ得点ラインに達していない列だけを管理する)
struct SegTree {
    static constexpr ll NEG = LLONG_MIN / 4;
    int size;
    vector<ll> mx, lz;
    SegTree(int n) {
        size = 1;
        while (size < n) size <<= 1;
        mx.assign(2 * size, NEG);
        lz.assign(2 * size, 0);
        for (int i = 0; i < n; i++) mx[size + i] = 0;
        for (int i = size - 1; i >= 1; i--) mx[i] = max(mx[2 * i], mx[2 * i + 1]);
    }
    void push(int k) {
        if (lz[k]) {
            for (int c : {2 * k, 2 * k + 1}) {
                mx[c] += lz[k];
                lz[c] += lz[k];
            }
            lz[k] = 0;
        }
    }
    void add(int l, int r, ll v, int k, int nl, int nr) {
        if (r <= nl || nr <= l) return;
        if (l <= nl && nr <= r) {
            mx[k] += v;
            lz[k] += v;
            return;
        }
        push(k);
        int m = (nl + nr) / 2;
        add(l, r, v, 2 * k, nl, m);
        add(l, r, v, 2 * k + 1, m, nr);
        mx[k] = max(mx[2 * k], mx[2 * k + 1]);
    }
    void add(int l, int r, ll v) { add(l, r, v, 1, 0, size); }
    ll all_max() const { return mx[1]; }
    // 最大値を持つ葉を -inf にする
    void remove_max() {
        int k = 1;
        while (k < size) {
            push(k);
            k = (mx[2 * k] >= mx[2 * k + 1]) ? 2 * k : 2 * k + 1;
        }
        mx[k] = NEG;
        for (k >>= 1; k >= 1; k >>= 1) mx[k] = max(mx[2 * k], mx[2 * k + 1]);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    ll h;
    cin >> n >> w >> h;

    SegTree seg(w);
    ll ans = 0;
    int done = 0;
    for (int i = 0; i < n && done < w; i++) {
        int a, x;
        ll b;
        cin >> a >> b >> x;
        x--;
        seg.add(x, x + a, b);
        ll d = 0;
        while (seg.all_max() >= h) {
            seg.remove_max();
            d++;
        }
        done += d;
        ans += (i & 1 ? -d : d);
    }
    cout << (ans == 0 ? "DRAW" : ans > 0 ? "A" : "B") << '\n';
}
0