結果
問題 | No.1995 CHIKA Road |
ユーザー |
|
提出日時 | 2022-07-02 00:04:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 2,128 ms |
コンパイル使用メモリ | 199,428 KB |
最終ジャッジ日時 | 2025-01-30 03:37:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h>using namespace std;static inline void solve() {int n, m;cin >> n >> m;vector<pair<int, int>> P(m);for (int i = 0; i < m; i++) {int a, b;cin >> a >> b;P[i] = {b, a};}sort(P.begin(), P.end());int now = 1;int ans = 2 * (n - 1);for (int i = 0; i < m; i++) {auto [b, a] = P[i];if (now > a) continue;now = b;ans--;}cout << ans << '\n';}int main() {ios_base::sync_with_stdio(0), cin.tie(0);#ifdef LOCALint T;cin >> T;for (int tc = 1; tc <= T; tc++) {cout << "Case" << tc << ":" << '\n';solve();}#elsesolve();#endifreturn 0;}