Task: | Binge watching |
Sender: | aalto2024b_005 |
Submission time: | 2024-09-11 16:29:53 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.07 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.07 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp: In function 'void Test()': input/code.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 16 | freopen("temp\\in.txt", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 22 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ input/code.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 27 | scanf("%d%d", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~
Code
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> typedef long long LL; typedef std::pair<int, int> poi; using std::make_pair; const int N=200005; poi p[N]; void Test() { freopen("temp\\in.txt", "r", stdin); } int main() { // Test(); int n; scanf("%d", &n); for(int i=1; i<=n; i++) { int a, b; scanf("%d%d", &a, &b); p[i]=make_pair(a, b); } sort(p+1, p+n+1); int now = 0, ans = 0; for(int i=1; i<=n; i++) { int u = p[i].first, v = p[i].second; if(now <= u) { ans++; now = v; } else { if(v < now) now = v; } } printf("%d", ans); 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 |