| Task: | Binge watching |
| Sender: | aalto25b_011 |
| Submission time: | 2025-09-10 17:57:49 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | TIME LIMIT EXCEEDED | -- | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | ACCEPTED | 0.28 s | details |
| #7 | ACCEPTED | 0.00 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | ACCEPTED | 0.00 s | details |
Code
// #include <bits/stdc++.h>
#include <algorithm>
#include <ios>
#include <iostream>
#include <vector>
// #include <iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define DO_DBG 1
#if DO_DBG
#define DBG(x) cerr << x << "\n";
#else
#define DBG(x)
#endif
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
DBG("INIT")
int n;
cin >> n;
vpi movies;
for (int i = 0; i < n; i++) {
int start, end;
cin >> start >> end;
movies.PB(MP(start, end));
}
std::sort(movies.begin(), movies.end(),
[](auto &left, auto &right) { return left.second < right.second; });
vpi chain;
while (1) {
int earliest_end = 0;
pi nxt = {};
for (auto m : movies) {
// we build the chain by continously picking the next movie by
// finding a movie that
// a) ends as early as possible
// b) starts after the last movie in the current chain ends (or if the
// chain is empty)
if ((earliest_end == 0 || m.S < earliest_end) &&
(chain.empty() || m.F >= chain.back().S)) {
earliest_end = m.S;
nxt = m;
}
}
if (earliest_end == 0) {
break;
}
chain.push_back(nxt);
}
DBG("NEW CHAIN:")
for (auto m : chain) {
DBG("start: " << m.F << ", end: " << m.S)
}
DBG("size: " << chain.size() << "\n")
cout << chain.size() << "\n";
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 10 6 7 4 5 8 9 2 3 ... |
| correct output |
|---|
| 10 |
| user output |
|---|
| 10 |
Error:
INIT NEW CHAIN: start: 1, end: 2 start: 2, end: 3 start: 3, end: 4 start: 4, end: 5 start:...
Test 2
Verdict: ACCEPTED
| input |
|---|
| 10 1 1000 1 1000 1 1000 1 1000 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Error:
INIT NEW CHAIN: start: 1, end: 1000 size: 1
Test 3
Verdict: ACCEPTED
| input |
|---|
| 10 404 882 690 974 201 255 800 933 ... |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Error:
INIT NEW CHAIN: start: 201, end: 255 start: 457, end: 601 start: 699, end: 804 start: 832,...
Test 4
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 177494 177495 157029 157030 6030 6031 15209 15210 ... |
| correct output |
|---|
| 200000 |
| user output |
|---|
| (empty) |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 200000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 ... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Error:
INIT NEW CHAIN: start: 1, end: 1000000000 size: 1
Test 6
Verdict: ACCEPTED
| input |
|---|
| 200000 82334756 323555178 958182284 981100325 649818003 678160906 801994655 889397498 ... |
| correct output |
|---|
| 725 |
| user output |
|---|
| 725 |
Error:
INIT NEW CHAIN: start: 722928, end: 1399549 start: 3340526, end: 4902968 start: 6322519, e...
Test 7
Verdict: ACCEPTED
| input |
|---|
| 3 1 1000 2 3 5 6 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
Error:
INIT NEW CHAIN: start: 2, end: 3 start: 5, end: 6 size: 2
Test 8
Verdict: ACCEPTED
| input |
|---|
| 3 3 4 5 6 7 8 |
| correct output |
|---|
| 3 |
| user output |
|---|
| 3 |
Error:
INIT NEW CHAIN: start: 3, end: 4 start: 5, end: 6 start: 7, end: 8 size: 3
Test 9
Verdict: ACCEPTED
| input |
|---|
| 2 1 2 3 4 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
Error:
INIT NEW CHAIN: start: 1, end: 2 start: 3, end: 4 size: 2
