結果

問題 No.2650 [Cherry 6th Tune *] セイジャク
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2024-02-23 23:02:07
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,142 bytes
コンパイル時間 5,430 ms
コンパイル使用メモリ 261,664 KB
実行使用メモリ 13,068 KB
最終ジャッジ日時 2024-02-23 23:02:24
合計ジャッジ時間 14,677 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 115 ms
6,676 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 296 ms
13,068 KB
testcase_10 AC 303 ms
13,068 KB
testcase_11 AC 290 ms
13,068 KB
testcase_12 AC 302 ms
13,068 KB
testcase_13 AC 302 ms
13,068 KB
testcase_14 AC 295 ms
13,068 KB
testcase_15 AC 294 ms
13,068 KB
testcase_16 AC 287 ms
13,068 KB
testcase_17 AC 277 ms
13,068 KB
testcase_18 AC 289 ms
13,068 KB
testcase_19 AC 296 ms
13,068 KB
testcase_20 AC 287 ms
13,068 KB
testcase_21 AC 286 ms
13,068 KB
testcase_22 AC 286 ms
13,068 KB
testcase_23 AC 286 ms
13,068 KB
testcase_24 AC 280 ms
13,068 KB
testcase_25 AC 278 ms
13,068 KB
testcase_26 AC 288 ms
13,068 KB
testcase_27 AC 285 ms
13,068 KB
testcase_28 AC 281 ms
13,068 KB
testcase_29 AC 278 ms
13,068 KB
testcase_30 AC 281 ms
13,068 KB
testcase_31 AC 308 ms
13,068 KB
testcase_32 AC 198 ms
8,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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



int main() {
    int n,a;
    cin >> n >> a;

    vector<int> X(n);
    for (auto& x: X) cin >> x;

    int t;
    cin >> t;
    vector<int> L(n),R(n);
    for (int i = 0; i < t; i++){
        cin >> L[i] >> R[i];
    } 

    vector<array<int,3>> event;
    vector<int> used(t,0);
    vector<int> ans(n,-1);

    priority_queue<pair<int,int>> h;

    for (int i = 0; i < n; i++){
        event.push_back({X[i],0,i});
    }

    for (int i = 0; i < t; i++){
        event.push_back({L[i],-1,i});
        event.push_back({R[i],1,i});
    }
    
    sort(event.begin(),event.end());

    for (auto [t,f,ind] : event){
        if (f == 0){
            while (!h.empty()){
                auto [t,ind] = h.top();
                if (used[ind]) h.pop();
                else break;
            }
            if (!h.empty()){
                ans[ind] = h.top().first;
            }

        }
        if (f == -1){
            h.push({ind+1,ind});
        }
        if (f == 1){
            used[ind] = 1;
        }
    }
    
    for (auto a: ans){
        cout << a << endl;
    }

    return 0;
}
0