結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 4 ms
6,676 KB
testcase_02 AC 131 ms
6,676 KB
testcase_03 AC 33 ms
6,676 KB
testcase_04 AC 178 ms
8,992 KB
testcase_05 AC 142 ms
7,916 KB
testcase_06 AC 76 ms
6,676 KB
testcase_07 AC 140 ms
8,244 KB
testcase_08 AC 58 ms
6,676 KB
testcase_09 AC 288 ms
13,068 KB
testcase_10 AC 330 ms
13,068 KB
testcase_11 AC 289 ms
13,068 KB
testcase_12 AC 298 ms
13,068 KB
testcase_13 AC 311 ms
13,068 KB
testcase_14 AC 297 ms
13,068 KB
testcase_15 AC 291 ms
13,068 KB
testcase_16 AC 286 ms
13,068 KB
testcase_17 AC 305 ms
13,068 KB
testcase_18 AC 289 ms
13,068 KB
testcase_19 AC 290 ms
13,068 KB
testcase_20 AC 290 ms
13,068 KB
testcase_21 AC 315 ms
13,068 KB
testcase_22 AC 285 ms
13,068 KB
testcase_23 AC 282 ms
13,068 KB
testcase_24 AC 281 ms
13,068 KB
testcase_25 AC 306 ms
13,068 KB
testcase_26 AC 283 ms
13,068 KB
testcase_27 AC 284 ms
13,068 KB
testcase_28 AC 282 ms
13,068 KB
testcase_29 AC 305 ms
13,068 KB
testcase_30 AC 283 ms
13,068 KB
testcase_31 AC 291 ms
13,068 KB
testcase_32 AC 203 ms
7,472 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(t),R(t);
    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