結果
| 問題 |
No.2796 Small Matryoshka
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-28 21:56:24 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 719 bytes |
| コンパイル時間 | 1,505 ms |
| コンパイル使用メモリ | 94,856 KB |
| 実行使用メモリ | 14,948 KB |
| 最終ジャッジ日時 | 2024-06-28 21:56:30 |
| 合計ジャッジ時間 | 5,912 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 1 TLE * 1 -- * 12 |
ソースコード
#include <iostream>
#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;
priority_queue<P, vector<P>, greater<P>> que1, que2;
for (int i = 0; i < N; i++)
que1.push(r[i]);
while (!que1.empty()) {
P mat = que1.top(); 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;
}