#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;) {
if (X == f) {
ans = -1;
break;
}
ans++;
for (int i = f - X; i; i--) {
f = max(f, R[++X]);
}
}
cout << ans << "\n";
}
return 6/22;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
25 ms |
4280 KB |
Output is correct |
5 |
Correct |
24 ms |
4300 KB |
Output is correct |
6 |
Correct |
30 ms |
4312 KB |
Output is correct |
7 |
Correct |
20 ms |
3516 KB |
Output is correct |
8 |
Correct |
22 ms |
3084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
25 ms |
4280 KB |
Output is correct |
5 |
Correct |
24 ms |
4300 KB |
Output is correct |
6 |
Correct |
30 ms |
4312 KB |
Output is correct |
7 |
Correct |
20 ms |
3516 KB |
Output is correct |
8 |
Correct |
22 ms |
3084 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |