結果

問題 No.1557 Binary Variable
コンテスト
ユーザー noya2
提出日時 2021-04-18 13:51:02
言語 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  
実行時間 116 ms / 2,000 ms
+ 176µs
コード長 593 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,294 ms
コンパイル使用メモリ 283,160 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-11-27 22:17:31
合計ジャッジ時間 12,694 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using namespace atcoder;
using namespace internal;
using P = pair<int, int>;

template <typename SD>
void sor(vector<SD> &ar){sort(ar.begin(),ar.end());}

int main(){
    int n, m; cin >> n >> m;
    int ans = n;
    vector<P> ar(m);
    rep(i,m){
        int l, r; cin >> l >> r;
        ar[i] = P(r,l-1);
    }
    sor(ar);
    int t = 0;
    rep(i,m){
        if (t <= ar[i].second){
            ans--;
            t = ar[i].first;
        }
    }
    cout << ans << endl;
}
0