結果
| 問題 | No.1995 CHIKA Road |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-24 17:08:27 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 641 bytes |
| 記録 | |
| コンパイル時間 | 1,084 ms |
| コンパイル使用メモリ | 188,200 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-03-12 17:32:23 |
| 合計ジャッジ時間 | 3,894 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<ll, ll> P;
const long long INF = 1e17;
void solve() {
ll N, M; cin >> N >> M;
vector<P>A(M);
for (ll i = 0; i < M; i++) {
cin >> A[i].second >> A[i].first;
}
sort(A.begin(), A.end());
ll ans = 0, pos = 0;
for (ll i = 0; i < M; i++) {
if (A[i].second >= pos) {
ans++;
pos = A[i].first;
}
}
cout << 2 * (N - 1) - ans << endl;
}
int main() {
ll T = 1; //cin >> T;
while (T--) {
solve();
}
}