#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 200200;
pair < int, int > pass[N];
int n, q, x;
void solve_subtask_1() {
int ans = 1, pr_r = 1, cr_r = pass[1].second, nw_r = 1;
for(; cr_r < n;) {
nw_r = cr_r;
for(int r = pr_r + 1; r <= cr_r; ++ r) {
if(pass[r].second > nw_r) {
nw_r = pass[r].second;
}
}
if(nw_r == cr_r) {
cout << "-1";
return;
}
++ ans;
pr_r = cr_r;
cr_r = nw_r;
}
cout << ans << '\n';
}
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++ i) {
cin >> pass[i].first >> pass[i].second;
}
cin >> q >> x;
if(q == 1 && x == 1) {
solve_subtask_1();
return 0;
}
}
Compilation message
passport.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
37 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
24 ms |
1780 KB |
Output is correct |
5 |
Correct |
23 ms |
1812 KB |
Output is correct |
6 |
Correct |
24 ms |
1836 KB |
Output is correct |
7 |
Correct |
19 ms |
1748 KB |
Output is correct |
8 |
Correct |
16 ms |
1476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
24 ms |
1780 KB |
Output is correct |
5 |
Correct |
23 ms |
1812 KB |
Output is correct |
6 |
Correct |
24 ms |
1836 KB |
Output is correct |
7 |
Correct |
19 ms |
1748 KB |
Output is correct |
8 |
Correct |
16 ms |
1476 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |