結果

問題 No.2667 Constrained Permutation
ユーザー suisensuisen
提出日時 2023-10-29 22:41:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 928 bytes
コンパイル時間 941 ms
コンパイル使用メモリ 99,712 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2024-01-15 12:25:35
合計ジャッジ時間 5,440 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,516 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 4 ms
6,676 KB
testcase_04 AC 9 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 6 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 7 ms
6,676 KB
testcase_09 AC 6 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 5 ms
6,676 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>

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

    int n;
    std::cin >> n;

    std::vector<std::pair<int, int>> lr(n);
    for (auto& [l, r] : lr) std::cin >> l >> r;

    std::sort(lr.begin(), lr.end());

    int ans = 0;
    for (int k = lr[0].first - 1; k < lr.back().first; ++k) {
        bool ok = true;

        std::priority_queue<int, std::vector<int>, std::greater<int>> pq;

        for (int i = 1, j = 0; i <= n; ++i) {
            while (j < n and lr[j].first <= k + i) {
                pq.push(lr[j++].second);
            }
            if (pq.empty() or pq.top() < k + i) {
                ok = false;
                break;
            }
            pq.pop();
        }
        if (ok) {
            ++ans;
        }
    }
    std::cout << ans << std::endl;
}
0