結果

問題 No.2667 Constrained Permutation
ユーザー みここみここ
提出日時 2024-03-08 21:49:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 81,028 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-08 21:49:32
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,548 KB
testcase_01 AC 3 ms
6,548 KB
testcase_02 AC 3 ms
6,548 KB
testcase_03 AC 3 ms
6,548 KB
testcase_04 AC 3 ms
6,548 KB
testcase_05 AC 3 ms
6,548 KB
testcase_06 AC 3 ms
6,548 KB
testcase_07 AC 3 ms
6,548 KB
testcase_08 AC 4 ms
6,548 KB
testcase_09 AC 4 ms
6,548 KB
testcase_10 AC 3 ms
6,548 KB
testcase_11 AC 3 ms
6,548 KB
testcase_12 AC 68 ms
6,548 KB
testcase_13 AC 6 ms
6,548 KB
testcase_14 AC 188 ms
6,548 KB
testcase_15 AC 154 ms
6,548 KB
testcase_16 AC 103 ms
6,548 KB
testcase_17 AC 34 ms
6,548 KB
testcase_18 AC 199 ms
6,548 KB
testcase_19 AC 200 ms
6,548 KB
testcase_20 AC 202 ms
6,548 KB
testcase_21 AC 188 ms
6,548 KB
testcase_22 AC 205 ms
6,548 KB
testcase_23 AC 190 ms
6,548 KB
testcase_24 AC 83 ms
6,548 KB
testcase_25 AC 156 ms
6,548 KB
testcase_26 AC 197 ms
6,548 KB
testcase_27 AC 192 ms
6,548 KB
testcase_28 AC 160 ms
6,548 KB
testcase_29 AC 133 ms
6,548 KB
testcase_30 AC 148 ms
6,548 KB
testcase_31 AC 92 ms
6,548 KB
testcase_32 AC 22 ms
6,548 KB
testcase_33 WA -
testcase_34 AC 100 ms
6,548 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 144 ms
6,548 KB
testcase_39 AC 5 ms
6,548 KB
testcase_40 AC 102 ms
6,548 KB
testcase_41 AC 161 ms
6,548 KB
testcase_42 AC 111 ms
6,548 KB
testcase_43 AC 164 ms
6,548 KB
testcase_44 AC 70 ms
6,548 KB
testcase_45 AC 5 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    P p[200005];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i].first >> p[i].second;
    }
    int l = 0;
    sort(p, p + n);
    for (int i = 0; i < n; i++)
    {
        l = max(l, p[i].first - (i + 1));
    }
    for (int i = 0; i < n; i++)
    {
        swap(p[i].first, p[i].second);
    }
    int r = 2000000000;
    sort(p, p + n);
    for (int i = 0; i < n; i++)
    {
        r = min(r, p[i].first - (i + 1));
    }
    cout << max(0, r - l + 1) << endl;
}
0