#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<int> L(N), R(N);
for (int i = 0; i < N; i++) {
cin >> L[i] >> R[i];
L[i]--, R[i]--;
}
int Q; cin >> Q; while (Q--) {
int X;
cin >> X;
X--;
int ans = 0;
for (int f = R[0]; X < N - 1;) {
ans++;
if (X == f) {
ans = -1;
break;
}
for (int i = f - X; i; i--, X++) {
f = max(f, R[X]);
}
}
cout << ans << "\n";
}
return 6/22;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
252 KB |
Output is correct |
4 |
Correct |
25 ms |
4308 KB |
Output is correct |
5 |
Incorrect |
24 ms |
4308 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
320 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 |
320 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 |
320 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 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
252 KB |
Output is correct |
4 |
Correct |
25 ms |
4308 KB |
Output is correct |
5 |
Incorrect |
24 ms |
4308 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |