#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int x,q,l[N],r[N],nxt[N];
int main(){
ios::sync_with_stdio(0);cin.tie(0);
cin>>x;
for(int i=1;i<=x;i++)cin>>l[i]>>r[i];
for(int i=x;i>=1;i--){
nxt[i]=(i<x?nxt[i+1]:i+1);
for(int j=x;j>i;j--)
if(max(l[i],l[j])<=min(r[i],r[j]))
nxt[i]=min(nxt[i],j);
}
cin>>q;
while(q--){
int c1,c2,ans=0;cin>>c1>>c2;
while(c1<=c2){
ans++;
c1=nxt[c1];
}
cout<<ans<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
21 ms |
4172 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
69 ms |
524 KB |
Output is correct |
2 |
Correct |
60 ms |
592 KB |
Output is correct |
3 |
Correct |
59 ms |
628 KB |
Output is correct |
4 |
Correct |
67 ms |
524 KB |
Output is correct |
5 |
Correct |
57 ms |
512 KB |
Output is correct |
6 |
Correct |
59 ms |
536 KB |
Output is correct |
7 |
Correct |
47 ms |
468 KB |
Output is correct |
8 |
Correct |
51 ms |
468 KB |
Output is correct |
9 |
Correct |
41 ms |
524 KB |
Output is correct |
10 |
Correct |
29 ms |
520 KB |
Output is correct |
11 |
Correct |
14 ms |
468 KB |
Output is correct |
12 |
Correct |
14 ms |
500 KB |
Output is correct |
13 |
Correct |
14 ms |
496 KB |
Output is correct |
14 |
Correct |
14 ms |
468 KB |
Output is correct |
15 |
Correct |
16 ms |
500 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
87 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
69 ms |
524 KB |
Output is correct |
2 |
Correct |
60 ms |
592 KB |
Output is correct |
3 |
Correct |
59 ms |
628 KB |
Output is correct |
4 |
Correct |
67 ms |
524 KB |
Output is correct |
5 |
Correct |
57 ms |
512 KB |
Output is correct |
6 |
Correct |
59 ms |
536 KB |
Output is correct |
7 |
Correct |
47 ms |
468 KB |
Output is correct |
8 |
Correct |
51 ms |
468 KB |
Output is correct |
9 |
Correct |
41 ms |
524 KB |
Output is correct |
10 |
Correct |
29 ms |
520 KB |
Output is correct |
11 |
Correct |
14 ms |
468 KB |
Output is correct |
12 |
Correct |
14 ms |
500 KB |
Output is correct |
13 |
Correct |
14 ms |
496 KB |
Output is correct |
14 |
Correct |
14 ms |
468 KB |
Output is correct |
15 |
Correct |
16 ms |
500 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
87 ms |
596 KB |
Output is correct |
18 |
Correct |
570 ms |
3152 KB |
Output is correct |
19 |
Correct |
509 ms |
3064 KB |
Output is correct |
20 |
Correct |
583 ms |
3120 KB |
Output is correct |
21 |
Correct |
516 ms |
2944 KB |
Output is correct |
22 |
Correct |
554 ms |
3112 KB |
Output is correct |
23 |
Correct |
645 ms |
3148 KB |
Output is correct |
24 |
Correct |
497 ms |
3036 KB |
Output is correct |
25 |
Correct |
408 ms |
3072 KB |
Output is correct |
26 |
Correct |
325 ms |
3168 KB |
Output is correct |
27 |
Correct |
228 ms |
2844 KB |
Output is correct |
28 |
Correct |
50 ms |
2512 KB |
Output is correct |
29 |
Correct |
54 ms |
2560 KB |
Output is correct |
30 |
Correct |
55 ms |
2564 KB |
Output is correct |
31 |
Correct |
52 ms |
2552 KB |
Output is correct |
32 |
Correct |
56 ms |
2476 KB |
Output is correct |
33 |
Correct |
1 ms |
328 KB |
Output is correct |
34 |
Execution timed out |
1087 ms |
1900 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
4172 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
21 ms |
4172 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |