結果

問題 No.1557 Binary Variable
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-12 00:14:23
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 112,928 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-03 06:09:16
合計ジャッジ時間 10,465 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    int N, M, l, r, now=-1;
    cin >> N >> M;
    vector<pair<int, int>> RL(M);
    for (int i=0; i<M; i++){
        cin >> l >> r;
        RL[i] = {r, l};
    }
    sort(RL.begin(), RL.end());
    for (int i=0; i<M; i++){
        tie(r, l) = RL[i];
        if (now < l){
            now = r;
            N--;
        }
    }

    cout << N << endl;

    return 0;
}
0