結果
| 問題 |
No.1557 Binary Variable
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2021-06-25 23:11:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 177 ms / 2,000 ms |
| コード長 | 728 bytes |
| コンパイル時間 | 1,709 ms |
| コンパイル使用メモリ | 177,448 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 08:50:52 |
| 合計ジャッジ時間 | 8,199 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,pair<int,int>>>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000
int main(){
int N,M;
cin>>N>>M;
vector<pair<int,int>> lr(M);
for(int i=0;i<M;i++){
cin>>lr[i].first>>lr[i].second;
}
sort(lr.begin(),lr.end());
priority_queue<int,vector<int>,greater<int>> pq;
int i=0;
int cnt=0;
while(i<M){
if(i<M&&pq.empty()){
pq.push(lr[i].second);
i++;
}
while(i<M&&lr[i].first<=pq.top()){
pq.push(lr[i].second);
i++;
}
cnt++;
while(!pq.empty()){
pq.pop();
}
}
cout<<N-cnt<<endl;
}
monnu