結果

問題 No.3327 うるせぇ、ポリオミノぶつけんぞ
コンテスト
ユーザー i_taku
提出日時 2026-01-20 10:18:58
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 386 ms / 3,000 ms
コード長 847 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,153 ms
コンパイル使用メモリ 218,236 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-01-20 10:19:08
合計ジャッジ時間 8,618 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;


int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}

int x;
bool f(int v) {
    return v <= x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    atcoder::segtree<int, op, e> seg(A);

    while (Q--) {
        int c;
        cin >> c >> x;
        if (seg.all_prod() <= x) {
            cout << "-1\n";
            continue;
        }
        if (c == 1) {
            int idx = seg.max_right<f>(0);
            cout << idx + 1 << endl;
            seg.set(idx, 0);
        } else {
            int idx = seg.min_left<f>(N);
            cout << idx << endl;
            seg.set(idx - 1, 0);
        }
    }
}
0