結果
| 問題 |
No.1995 CHIKA Road
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-01 23:02:26 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 2,000 ms |
| コード長 | 756 bytes |
| コンパイル時間 | 1,547 ms |
| コンパイル使用メモリ | 146,344 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-26 06:47:36 |
| 合計ジャッジ時間 | 3,909 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> a(m);
vector<int> dp(2 * m, 0);
map<int, int> mp;
for(int i = 0; i < m; i++) {
cin >> a[i].second >> a[i].first;
}
sort(a.begin(), a.end());
for(int i = 0; i < m; i++) {
swap(a[i].first, a[i].second);
}
int now = 0;
int cnt = 0;
for(int i = 0; i < m; i++) {
if(now <= a[i].first) {
now = a[i].second;
cnt++;
}
}
cout << n * 2 - 2 - cnt << endl;
return 0;
}