結果

問題 No.1995 CHIKA Road
ユーザー SSRS
提出日時 2022-07-01 21:26:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 173,900 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 03:44:53
合計ジャッジ時間 5,233 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < M; i++){
    cin >> A[i] >> B[i];
  }
  vector<pair<int, int>> P(M);
  for (int i = 0; i < M; i++){
    P[i] = make_pair(B[i], A[i]);
  }
  sort(P.begin(), P.end());
  int q = 0;
  int c = 0;
  for (int i = 0; i < M; i++){
    if (q <= P[i].second){
      q = P[i].first;
      c++;
    }
  }
  cout << (N - 1) * 2 - c << endl;
}
0