結果

問題 No.2667 Constrained Permutation
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-08 22:55:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 2,830 ms
コンパイル使用メモリ 212,268 KB
実行使用メモリ 28,544 KB
最終ジャッジ日時 2024-03-08 22:55:15
合計ジャッジ時間 11,993 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 94 ms
11,904 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 390 ms
26,880 KB
testcase_15 AC 260 ms
22,784 KB
testcase_16 AC 170 ms
17,024 KB
testcase_17 AC 39 ms
7,808 KB
testcase_18 AC 383 ms
28,544 KB
testcase_19 AC 413 ms
28,544 KB
testcase_20 AC 370 ms
28,544 KB
testcase_21 AC 357 ms
28,544 KB
testcase_22 AC 413 ms
28,544 KB
testcase_23 AC 334 ms
28,544 KB
testcase_24 AC 118 ms
14,208 KB
testcase_25 AC 284 ms
23,936 KB
testcase_26 AC 434 ms
28,544 KB
testcase_27 AC 380 ms
28,544 KB
testcase_28 AC 279 ms
22,144 KB
testcase_29 AC 259 ms
21,120 KB
testcase_30 AC 336 ms
23,424 KB
testcase_31 AC 144 ms
15,616 KB
testcase_32 AC 21 ms
6,676 KB
testcase_33 WA -
testcase_34 AC 159 ms
16,640 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 228 ms
22,016 KB
testcase_39 AC 4 ms
6,676 KB
testcase_40 AC 146 ms
16,512 KB
testcase_41 AC 261 ms
24,192 KB
testcase_42 AC 136 ms
17,408 KB
testcase_43 AC 191 ms
23,296 KB
testcase_44 AC 68 ms
11,904 KB
testcase_45 AC 4 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N; cin >> N;
    map<long long,long long> L;
    map<long long,long long,greater<>> R;
    for(long long i=0; i<N; i++){
        long long l,r; cin >> l >> r;
        L[l-N]++; R[r-1]++;
    }

    long long maxl = -1e9,minr = 2e9;
    for(auto [k,v] : L){
        if(v >= 2) L[k+1] += v-1;
        if(v) maxl = max(maxl,k);
    }
    for(auto [k,v] : R){
        if(v >= 2) R[k-1] += v-1;
        if(v) minr = min(minr,k);
    }

    cout << max(0LL,minr-maxl+1) << endl;
}
0