結果
問題 |
No.1995 CHIKA Road
|
ユーザー |
|
提出日時 | 2022-08-07 16:17:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 2,450 ms |
コンパイル使用メモリ | 199,456 KB |
最終ジャッジ日時 | 2025-01-30 19:14:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ll n,m; std::cin >> n>>m; vector<pair<ll,ll>> p(m); for (int i = 0; i < m; i++) { ll a,b; std::cin >> a>>b; p[i] = {b,a}; } sort(p.begin(),p.end()); ll now = 0; ll ans = n*2-2; for (int i = 0; i < m; i++) { if(now<=p[i].second){ now = p[i].first; ans--; } } std::cout << ans << std::endl; }