結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー nono00nono00
提出日時 2024-02-23 22:44:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 204 ms / 2,500 ms
コード長 1,075 bytes
コンパイル時間 4,990 ms
コンパイル使用メモリ 257,628 KB
実行使用メモリ 15,780 KB
最終ジャッジ日時 2024-02-23 22:44:45
合計ジャッジ時間 11,269 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 63 ms
10,112 KB
testcase_03 AC 9 ms
6,676 KB
testcase_04 AC 52 ms
8,380 KB
testcase_05 AC 44 ms
8,252 KB
testcase_06 AC 23 ms
6,676 KB
testcase_07 AC 44 ms
7,608 KB
testcase_08 AC 21 ms
6,676 KB
testcase_09 AC 127 ms
15,776 KB
testcase_10 AC 128 ms
15,780 KB
testcase_11 AC 123 ms
15,780 KB
testcase_12 AC 124 ms
15,780 KB
testcase_13 AC 130 ms
15,780 KB
testcase_14 AC 124 ms
15,780 KB
testcase_15 AC 125 ms
15,780 KB
testcase_16 AC 187 ms
15,780 KB
testcase_17 AC 184 ms
15,776 KB
testcase_18 AC 184 ms
15,780 KB
testcase_19 AC 183 ms
15,780 KB
testcase_20 AC 204 ms
15,780 KB
testcase_21 AC 185 ms
15,780 KB
testcase_22 AC 186 ms
15,780 KB
testcase_23 AC 142 ms
15,780 KB
testcase_24 AC 141 ms
15,780 KB
testcase_25 AC 140 ms
15,780 KB
testcase_26 AC 141 ms
15,780 KB
testcase_27 AC 155 ms
15,780 KB
testcase_28 AC 143 ms
15,780 KB
testcase_29 AC 143 ms
15,780 KB
testcase_30 AC 150 ms
15,780 KB
testcase_31 AC 135 ms
15,780 KB
testcase_32 AC 128 ms
15,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

void solve() {
    int n, a;
    std::cin >> n >> a;
    std::map<int, std::vector<int>> pos;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        pos[x].push_back(i);
    }
    std::vector<int> ans(n, -1);
    int t;
    std::cin >> t;
    std::vector<std::pair<int, int>> intervals;
    for (int i = 0; i < t; i++) {
        int l, r;
        std::cin >> l >> r;
        r++;
        intervals.emplace_back(l, r);
    }
    for (int i = t - 1; i >= 0; i--) {
        auto [l, r] = intervals[i];
        while (true) {
            auto it = pos.lower_bound(l);
            if (it == pos.end()) break;
            if (it->first >= r) break;
            for (auto j: it->second) {
                ans[j] = i;
            }
            pos.erase(it);
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << (ans[i] == -1 ? -1 : ans[i] + 1) << '\n';
    }
}

int main() {
    std::cin.tie(0)->sync_with_stdio(0);
    std::cout << std::fixed << std::setprecision(16);
    int t = 1;

    while (t--) solve();
}
0