結果
| 問題 | 
                            No.1557 Binary Variable
                             | 
                    
| コンテスト | |
| ユーザー | 
                             mamimume____mo
                         | 
                    
| 提出日時 | 2021-07-26 13:06:01 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 179 ms / 2,000 ms | 
| コード長 | 746 bytes | 
| コンパイル時間 | 1,635 ms | 
| コンパイル使用メモリ | 175,064 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-22 02:51:34 | 
| 合計ジャッジ時間 | 8,549 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 34 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll INFL = 2e18;
template <class T>bool chmin(T &a, T b){ if (a > b) { a = b; return true;} else return false;}
template <class T>bool chmax(T &a, T b){ if (a < b) { a = b; return true;} else return false;}
int main() {
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> RL;
    for (int i = 0;i < M;i++) {
        int L,R;
        cin >> L >> R;
        RL.push_back({R,L});
    }
    sort(RL.begin(), RL.end());
    int cnt = 0;
    for (int i = 0;i < M;i++) {
        int j = i;
        while (j < M && RL[i].first >= RL[j].second) {
            j++;
        }
        cnt++;
        i = j-1;
    }
    cout << N - cnt << endl;
}
            
            
            
        
            
mamimume____mo