Submission details
Task:Binge watching
Sender:aalto26bw_009
Submission time:2026-09-09 16:43:55 +0300
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.07 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.07 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails

Code

// #ifdef ONLINE_JUDGE
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #endif
#include "bits/stdc++.h"
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i, a, b) for(__typeof(b) i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for(__typeof(a) i = a, _b = b; i >= _b; --i)
#define ALL(a) (a).begin(), (a).end()
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define dq deque<int>
#define nend '\n'
using namespace std;

const ll inf = 1e18;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int MOD = 1e9 + 7; 
const ll hashi = 2e9 + 11;

inline ll add(ll a, ll b) { return (a + b) % MOD; }
inline ll sub(ll a, ll b) { return ((a - b) % MOD + MOD) % MOD; }
inline ll mul(ll a, ll b) { return (a * b) % MOD; }

inline ll binpow(ll a, ll b) {
    ll res = 1;
    a %= MOD;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

inline ll modInverse(ll n) {
    return binpow(n, MOD - 2);
}

inline ll modDivide(ll a, ll b) {
    return (a % MOD * modInverse(b)) % MOD;
}

ll extended_gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1; y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extended_gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

void init_code() {
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
}

void solve() {
    int n;
    cin >> n;

    vector<ii> a(n);

    FOR(i, 0, n - 1) {
        cin >> a[i].fi >> a[i].se;
    }

    sort(ALL(a), [](ii x, ii y) {
        return x.se < y.se;
    });

    int ans = 0;
    int last = 0;

    FOR(i, 0, n - 1) {
        if (a[i].fi >= last) {
            ans++;
            last = a[i].se;
        }
    }

    cout << ans << nend;
}

int main() {
    init_code();

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }

    // #ifndef ONLINE_JUDGE
    // cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    // #endif

    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
10
6 7
4 5
8 9
2 3
...

correct output
10

user output
10

Test 2

Verdict: ACCEPTED

input
10
1 1000
1 1000
1 1000
1 1000
...

correct output
1

user output
1

Test 3

Verdict: ACCEPTED

input
10
404 882
690 974
201 255
800 933
...

correct output
4

user output
4

Test 4

Verdict: ACCEPTED

input
200000
177494 177495
157029 157030
6030 6031
15209 15210
...

correct output
200000

user output
200000

Test 5

Verdict: ACCEPTED

input
200000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
...

correct output
1

user output
1

Test 6

Verdict: ACCEPTED

input
200000
82334756 323555178
958182284 981100325
649818003 678160906
801994655 889397498
...

correct output
725

user output
725

Test 7

Verdict: ACCEPTED

input
3
1 1000
2 3
5 6

correct output
2

user output
2

Test 8

Verdict: ACCEPTED

input
3
3 4
5 6
7 8

correct output
3

user output
3

Test 9

Verdict: ACCEPTED

input
2
1 2
3 4

correct output
2

user output
2