Submission details
Task:Binge watching
Sender:aalto25b_003
Submission time:2025-09-10 17:05:48 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.09 sdetails
#5ACCEPTED0.06 sdetails
#60.10 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     while(indexa < a.size() and indexb < b.size()) {
      |           ~~~~~~~^~~~~~~~~~
input/code.cpp:22:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     while(indexa < a.size() and indexb < b.size()) {
      |                                 ~~~~~~~^~~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n; 
    cin >> n;
    vector<long long> a;
    vector<long long> b;
    
    while (n > 0) {
        n--;
        int l, r;
        cin >> l >> r;
        a.push_back(l);
        b.push_back(r);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    int res = 0;
    int indexa = 0, indexb = 0;
    while(indexa < a.size() and indexb < b.size()) {
        if (b[indexb] <= a[indexa]) {
            res++;
            indexb++;
            indexa++;
        } else {
            indexa++;
        }
    }
    cout << res + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();

    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:

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

correct output
725

user output
126567

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