結果

問題 No.1557 Binary Variable
ユーザー erbowlerbowl
提出日時 2022-09-18 18:55:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 3,027 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 205,096 KB
実行使用メモリ 6,464 KB
最終ジャッジ日時 2023-08-23 18:16:57
合計ジャッジ時間 11,056 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
6,188 KB
testcase_01 AC 128 ms
6,264 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 98 ms
6,268 KB
testcase_05 AC 102 ms
6,196 KB
testcase_06 AC 93 ms
6,152 KB
testcase_07 AC 93 ms
6,188 KB
testcase_08 AC 108 ms
6,200 KB
testcase_09 AC 107 ms
6,088 KB
testcase_10 AC 119 ms
6,128 KB
testcase_11 AC 116 ms
6,080 KB
testcase_12 AC 106 ms
6,192 KB
testcase_13 AC 119 ms
6,092 KB
testcase_14 AC 129 ms
6,088 KB
testcase_15 AC 115 ms
6,088 KB
testcase_16 AC 123 ms
6,116 KB
testcase_17 AC 124 ms
6,328 KB
testcase_18 AC 124 ms
6,192 KB
testcase_19 AC 136 ms
6,128 KB
testcase_20 AC 138 ms
6,200 KB
testcase_21 AC 136 ms
6,192 KB
testcase_22 AC 135 ms
6,288 KB
testcase_23 AC 135 ms
6,176 KB
testcase_24 AC 142 ms
6,180 KB
testcase_25 AC 140 ms
6,196 KB
testcase_26 AC 146 ms
6,152 KB
testcase_27 AC 147 ms
6,264 KB
testcase_28 AC 153 ms
6,148 KB
testcase_29 AC 159 ms
6,076 KB
testcase_30 AC 160 ms
6,188 KB
testcase_31 AC 163 ms
6,464 KB
testcase_32 AC 158 ms
6,184 KB
testcase_33 AC 139 ms
6,196 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

// modint
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() const { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr istream& operator >> (istream& is, Fp<MOD>& x) noexcept {
        is >> x.val;
        x.val %= MOD;
        if (x.val < 0) x.val += MOD;
        return is;
    }
    friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD>& r, long long n) noexcept {
        if (n == 0) return 1;
        if (n < 0) return modpow(modinv(r), -n);
        auto t = modpow(r, n / 2);
        t = t * t;
        if (n & 1) t = t * r;
        return t;
    }
    friend constexpr Fp<MOD> modinv(const Fp<MOD>& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b, swap(a, b);
            u -= t * v, swap(u, v);
        }
        return Fp<MOD>(u);
    }
};

// const int MOD = 1000000007;
//const int MOD = 998244353;
// using mint = Fp<MOD>;


signed main(){
    ll n,m;
    std::cin >> n>>m;
    vector<pair<ll,ll>> rl(m);
    for (int i = 0; i < m; i++) {
        std::cin >> rl[i].second>>rl[i].first;
    }
    sort(rl.begin(),rl.end());
    ll ans = 0;
    ll maxr = 0;
    for (int i = 0; i < m; i++) {
        if(rl[i].second<=maxr)continue;
        ans++;
        maxr = max(maxr,rl[i].first);
    }
    std::cout << n-ans << std::endl;
}
0