結果

問題 No.1557 Binary Variable
ユーザー mamimume____mo
提出日時 2021-07-26 12:53:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 896 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 174,856 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-22 02:34:20
合計ジャッジ時間 9,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#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>> LR;
    for (int i = 0;i < M;i++) {
        int L,R;
        cin >> L >> R;
        LR.push_back({L,R});
    }

    sort(LR.begin(), LR.end());

    int cnt = 0;
    for (int i = 0;i < M;i++) {
        int l,r;
        tie(l, r) = LR[i];
        int j = i;
        while (true) {
            int L,R;
            tie(L,R) = LR[j];
            if (max(l, L) <= min(r, R)) {
                j++;
            }
            else break;
        }

        cnt++;
        i = j - 1;
    }

    cout << N - cnt << endl;
}
0