結果
| 問題 |
No.1557 Binary Variable
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-06-25 21:24:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 2,000 ms |
| コード長 | 699 bytes |
| コンパイル時間 | 1,301 ms |
| コンパイル使用メモリ | 78,780 KB |
| 最終ジャッジ日時 | 2025-01-22 11:56:57 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int N,M;
vector<pair<int,int>> X;
int main(){
cin >> N >> M;
X.resize(M);
rep(i,M) cin >> X[i].first >> X[i].second;
sort(X.begin(),X.end());
int ans = N;
int fastR = N;
for(auto x : X){
if(x.first > fastR){
ans--;
fastR = x.second;
}
else{
fastR = min(fastR,x.second);
}
}
ans--;
cout << ans << "\n";
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_inst;
Nachia