結果

問題 No.2796 Small Matryoshka
ユーザー kenti
提出日時 2024-06-28 22:05:52
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 2,604 ms
コンパイル使用メモリ 110,428 KB
実行使用メモリ 13,472 KB
最終ジャッジ日時 2024-06-28 22:06:09
合計ジャッジ時間 5,564 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 1 TLE * 1 -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MAX_N = 200000;
int N;
P r[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> r[i].second >> r[i].first;
    int ans = -1, tmp = 0;
    sort(r, r + N);
    queue<P> que1, que2;
    for (int i = 0; i < N; i++)
        que1.push(r[i]);
    while (!que1.empty()) {
        P mat = que1.front(); que1.pop();
        if (mat.second >= tmp) {
            tmp = mat.first;
        } else
            que2.push(mat);
        if (que1.empty()) {
            swap(que1, que2);
            ans++;
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}
0