結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー InTheBloomInTheBloom
提出日時 2024-02-23 22:13:17
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 2,500 ms
コード長 1,359 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 127,436 KB
実行使用メモリ 12,328 KB
最終ジャッジ日時 2024-02-23 22:13:48
合計ジャッジ時間 8,765 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 45 ms
6,676 KB
testcase_03 AC 31 ms
6,676 KB
testcase_04 AC 171 ms
8,320 KB
testcase_05 AC 125 ms
7,168 KB
testcase_06 AC 60 ms
6,676 KB
testcase_07 AC 140 ms
7,552 KB
testcase_08 AC 44 ms
6,676 KB
testcase_09 AC 218 ms
10,024 KB
testcase_10 AC 223 ms
10,024 KB
testcase_11 AC 223 ms
10,024 KB
testcase_12 AC 224 ms
10,024 KB
testcase_13 AC 224 ms
10,024 KB
testcase_14 AC 224 ms
10,024 KB
testcase_15 AC 220 ms
10,024 KB
testcase_16 AC 169 ms
7,592 KB
testcase_17 AC 162 ms
7,592 KB
testcase_18 AC 168 ms
7,592 KB
testcase_19 AC 168 ms
7,592 KB
testcase_20 AC 168 ms
7,592 KB
testcase_21 AC 168 ms
7,592 KB
testcase_22 AC 169 ms
7,592 KB
testcase_23 AC 162 ms
7,720 KB
testcase_24 AC 163 ms
7,720 KB
testcase_25 AC 160 ms
7,720 KB
testcase_26 AC 164 ms
7,720 KB
testcase_27 AC 168 ms
7,720 KB
testcase_28 AC 162 ms
7,720 KB
testcase_29 AC 164 ms
7,720 KB
testcase_30 AC 165 ms
7,592 KB
testcase_31 AC 187 ms
12,328 KB
testcase_32 AC 79 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

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

    int T; cin >> T;

    enum ElementType {
        sound_begin,
        sound_end,
        person,
    };

    vector<tuple<int, int, int>> events(2*T + N);
    for (int t = 0; t < T; t++) {
        int L, R; cin >> L >> R;
        events[t] = make_tuple(L, t+1, sound_begin);
        events[T+t] = make_tuple(R+1, t+1, sound_end);
    }

    for (int i = 0; i < N; i++) events[2*T + i] = make_tuple(X[i], i, person);

    sort(events.begin(), events.end(),
            [](tuple<int, int, int> x, tuple<int, int, int> y) {
            if (get<0>(x) != get<0>(y)) return get<0>(x) < get<0>(y);
            if (get<2>(x) == person) return false;
            if (get<2>(y) == person) return true;
            return true; });

    vector<int> ans(N, -1);

    map<int, int> mp;

    for (auto& e : events) {
        if (get<2>(e) == person) {
            if (!mp.empty()) ans[get<1>(e)] = mp.rbegin()->first;
        }

        if (get<2>(e) == sound_begin) {
            mp[get<1>(e)] = 0;
        }

        if (get<2>(e) == sound_end) {
            mp.erase(get<1>(e));
        }
    }

    for (auto& v : ans) cout << v << "\n";
}
0