結果

問題 No.1557 Binary Variable
ユーザー Nzt3
提出日時 2022-10-13 16:42:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 2,271 ms
コンパイル使用メモリ 198,956 KB
最終ジャッジ日時 2025-02-08 02:43:23
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin>>N>>M;
  vector<array<int,2>>A(M);
  for(int i=0;i<M;i++){
    cin>>A[i][1]>>A[i][0];
  }
  int ans=N,l=0;
  sort(A.begin(),A.end());
  for(int i=0;i<M;i++){
    if(A[i][1]>l){
      --ans;
      l=A[i][0];
    }
  }
  cout<<ans<<'\n';
}
0