結果

問題 No.1995 CHIKA Road
ユーザー keisuke6
提出日時 2022-07-01 23:19:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 454 bytes
コンパイル時間 3,290 ms
コンパイル使用メモリ 252,820 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 07:16:25
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> S(M);
  int x;
  for(int i=0;i<M;i++){
      int a,b;
      cin>>a>>b;
      S[i] = {b,a};
  }
  sort(S.begin(),S.end());
  int now = S[0].second;
  int ans = 0;
  for(int i=1;i<M;i++){
      int b,a;
      tie(b,a) = S[i];
      if(now <= a){
          ans++;
          now = b;
      }
  }
  cout<<(N-1)*2-ans-1<<endl;
}
0