CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Results
Submission details
Task:Binge watching
Sender:aalto2024b_009
Submission time:2024-09-11 17:08:02 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#30.00 sdetails
#4ACCEPTED0.15 sdetails
#5ACCEPTED0.14 sdetails
#60.20 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.01 sdetails

Code

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct sort_pred {
    bool operator()(const std::pair<int,int> &left, const std::pair<int,int> &right) {
        return left.second < right.second;
    }
};

int main() {
    int n;
    cin >> n;

    vector<pair<int, int>> v;

    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        
        v.push_back({a,b});
    }
    sort(v.begin(), v.end(), sort_pred());
    
    int count = 1;
    int start;
    int end = v[0].second;
    for (int i = 1; i < n; i++){
        start = v[i].first;
        if (end <= start){
            count++;
            end = v[i-1].second;
        }
    }
    cout << count;

    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:

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

correct output
4

user output
5

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
730

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