結果

問題 No.2667 Constrained Permutation
ユーザー keisuke6keisuke6
提出日時 2024-03-08 23:00:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 212,280 KB
実行使用メモリ 8,060 KB
最終ジャッジ日時 2024-03-08 23:00:43
合計ジャッジ時間 9,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 134 ms
6,676 KB
testcase_29 AC 126 ms
6,676 KB
testcase_30 AC 142 ms
6,676 KB
testcase_31 AC 87 ms
6,676 KB
testcase_32 AC 20 ms
6,676 KB
testcase_33 AC 173 ms
6,676 KB
testcase_34 AC 98 ms
6,676 KB
testcase_35 AC 110 ms
6,676 KB
testcase_36 AC 104 ms
6,676 KB
testcase_37 AC 118 ms
6,676 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 95 ms
6,676 KB
testcase_41 AC 150 ms
6,676 KB
testcase_42 AC 566 ms
6,676 KB
testcase_43 AC 788 ms
8,060 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N;
    cin>>N;
    vector<pair<int,int>> S(N);
    for(int i=0;i<N;i++) cin>>S[i].first>>S[i].second;
    sort(S.begin(),S.end());
    int ind = 0;
    priority_queue<int,vector<int>,greater<int>> pq;
    for(int i=S[0].first;i<S[0].first+N;i++){
        while(ind != N && S[ind].first <= i){
            pq.push(S[ind].second);
            ind++;
        }
        if(pq.empty() || pq.top() < i){
            cout<<0<<endl;
            return 0;
        }
        pq.pop();
    }
    int l = 0;
    for(int z=30;z>=0;z--){
        while(pq.size()) pq.pop();
        ind = 0;
        l += (1ll<<z);
        bool p = true;
        for(int i=S[0].first+l;i<S[0].first+N+l;i++){
            while(ind != N && S[ind].first <= i){
                pq.push(S[ind].second);
                ind++;
            }
            if(pq.empty() || pq.top() < i){
                p = false;
                break;
            }
            pq.pop();
        }
        if(!p) l -= (1<<z);
    }
    cout<<1+l<<endl;
}
0