結果
| 問題 |
No.1995 CHIKA Road
|
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2024-12-01 16:03:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 100 ms / 2,000 ms |
| コード長 | 511 bytes |
| コンパイル時間 | 2,123 ms |
| コンパイル使用メモリ | 200,256 KB |
| 最終ジャッジ日時 | 2025-02-26 10:01:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m; cin >> n >> m;
vector<pair<int, int> > edges(m);
for(auto&[x, y] : edges){
cin >> x >> y;
--x, --y;
}
sort(edges.begin(), edges.end(), [](auto& l, auto& r) {
return (l.second < r.second);
});
int now = 0;
int ans = 2 * (n - 1);
for(auto&[x, y] : edges){
if(now > x){
continue;
}
now = y;
--ans;
}
cout << ans << endl;
return 0;
}
MasKoaTS