結果

問題 No.1557 Binary Variable
コンテスト
ユーザー srjywrdnprkt
提出日時 2023-06-12 00:14:23
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 118 ms / 2,000 ms
+ 315µs
コード長 642 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 850 ms
コンパイル使用メモリ 140,076 KB
実行使用メモリ 9,864 KB
最終ジャッジ日時 2026-11-27 22:59:49
合計ジャッジ時間 8,277 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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