結果

問題 No.1995 CHIKA Road
ユーザー Kanten4205
提出日時 2022-04-24 17:08:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 1,683 ms
コンパイル使用メモリ 173,708 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 04:02:24
合計ジャッジ時間 5,157 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
    }
}
0