結果
| 問題 |
No.1995 CHIKA Road
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-05-14 00:33:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 2,000 ms |
| コード長 | 738 bytes |
| コンパイル時間 | 981 ms |
| コンパイル使用メモリ | 109,296 KB |
| 最終ジャッジ日時 | 2025-02-13 00:19:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
template<typename T>
bool ord(T &x, T & y){
return x.second < y.second;
}
int main(){
int N, M, now=0, ans=0;
cin >> N >> M;
vector<pair<int, int>> AB(M);
for (int i=0; i<M; i++) cin >> AB[i].first >> AB[i].second;
sort(AB.begin(), AB.end(), ord<pair<int, int>>);
for (int i=0; i<M; i++){
if (now <= AB[i].first){
ans++;
now = AB[i].second;
}
}
cout << (N-1)*2-ans << endl;
return 0;
}
srjywrdnprkt