#include<bits/stdc++.h>
using namespace std;
map<int,vector<pair<int,int>>> ad,del,qr;
int ans[100100];
multiset<int>stor[401];
set<int>stuffhappens;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n,k,q;
cin>>n>>k>>q;
for(int i=0;i<n;i++){
int l,r,a,b;
cin>>a>>b>>l>>r;
ad[l].push_back({a,b});
del[r+1].push_back({a,b});
stuffhappens.insert(l);
stuffhappens.insert(r+1);
}
for(int i=0;i<q;i++){
int x,y; cin>>x>>y;
qr[y].push_back({x,i});
stuffhappens.insert(y);
}
for(auto year:stuffhappens){
for(auto[p,t]:ad[year])
stor[t].insert(p);
for(auto[p,t]:del[year])
stor[t].erase(stor[t].find(p));
for(auto[p,i]:qr[year]) {
int mx=0;
for(int t=1;t<=k;t++){
if(stor[t].empty()){
mx=-1;break;
}
int TIS=1e9;
auto it=stor[t].lower_bound(p);
if(it!=stor[t].end())TIS=*it-p;
if(it!=stor[t].begin())
TIS=min(TIS,p-*--it);
mx=max(mx,TIS);
}
ans[i]=mx;
}
}
for(int i=0;i<q;i++)
cout<<ans[i]<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
884 KB |
Output is correct |
7 |
Correct |
1 ms |
664 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
860 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
1 ms |
828 KB |
Output is correct |
26 |
Correct |
1 ms |
860 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
2 ms |
860 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
884 KB |
Output is correct |
7 |
Correct |
1 ms |
664 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
860 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
1 ms |
828 KB |
Output is correct |
26 |
Correct |
1 ms |
860 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
2 ms |
860 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1995 ms |
63076 KB |
Output is correct |
32 |
Correct |
48 ms |
4684 KB |
Output is correct |
33 |
Correct |
407 ms |
61268 KB |
Output is correct |
34 |
Correct |
1583 ms |
61300 KB |
Output is correct |
35 |
Correct |
1037 ms |
63316 KB |
Output is correct |
36 |
Correct |
430 ms |
63060 KB |
Output is correct |
37 |
Correct |
352 ms |
60496 KB |
Output is correct |
38 |
Correct |
285 ms |
60244 KB |
Output is correct |
39 |
Correct |
245 ms |
59988 KB |
Output is correct |
40 |
Correct |
263 ms |
60184 KB |
Output is correct |
41 |
Correct |
377 ms |
60244 KB |
Output is correct |
42 |
Correct |
353 ms |
60244 KB |
Output is correct |
43 |
Correct |
143 ms |
7752 KB |
Output is correct |
44 |
Correct |
378 ms |
60500 KB |
Output is correct |
45 |
Correct |
356 ms |
60244 KB |
Output is correct |
46 |
Correct |
221 ms |
60244 KB |
Output is correct |
47 |
Correct |
186 ms |
58264 KB |
Output is correct |
48 |
Correct |
178 ms |
57880 KB |
Output is correct |
49 |
Correct |
215 ms |
58912 KB |
Output is correct |
50 |
Correct |
324 ms |
59760 KB |
Output is correct |
51 |
Correct |
202 ms |
58708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
341 ms |
118748 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
815 ms |
237388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
884 KB |
Output is correct |
7 |
Correct |
1 ms |
664 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
860 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
1 ms |
828 KB |
Output is correct |
26 |
Correct |
1 ms |
860 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
2 ms |
860 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1995 ms |
63076 KB |
Output is correct |
32 |
Correct |
48 ms |
4684 KB |
Output is correct |
33 |
Correct |
407 ms |
61268 KB |
Output is correct |
34 |
Correct |
1583 ms |
61300 KB |
Output is correct |
35 |
Correct |
1037 ms |
63316 KB |
Output is correct |
36 |
Correct |
430 ms |
63060 KB |
Output is correct |
37 |
Correct |
352 ms |
60496 KB |
Output is correct |
38 |
Correct |
285 ms |
60244 KB |
Output is correct |
39 |
Correct |
245 ms |
59988 KB |
Output is correct |
40 |
Correct |
263 ms |
60184 KB |
Output is correct |
41 |
Correct |
377 ms |
60244 KB |
Output is correct |
42 |
Correct |
353 ms |
60244 KB |
Output is correct |
43 |
Correct |
143 ms |
7752 KB |
Output is correct |
44 |
Correct |
378 ms |
60500 KB |
Output is correct |
45 |
Correct |
356 ms |
60244 KB |
Output is correct |
46 |
Correct |
221 ms |
60244 KB |
Output is correct |
47 |
Correct |
186 ms |
58264 KB |
Output is correct |
48 |
Correct |
178 ms |
57880 KB |
Output is correct |
49 |
Correct |
215 ms |
58912 KB |
Output is correct |
50 |
Correct |
324 ms |
59760 KB |
Output is correct |
51 |
Correct |
202 ms |
58708 KB |
Output is correct |
52 |
Runtime error |
150 ms |
60756 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
480 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
884 KB |
Output is correct |
7 |
Correct |
1 ms |
664 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
860 KB |
Output is correct |
15 |
Correct |
1 ms |
860 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
1 ms |
860 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Correct |
1 ms |
860 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
1 ms |
828 KB |
Output is correct |
26 |
Correct |
1 ms |
860 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
2 ms |
860 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1995 ms |
63076 KB |
Output is correct |
32 |
Correct |
48 ms |
4684 KB |
Output is correct |
33 |
Correct |
407 ms |
61268 KB |
Output is correct |
34 |
Correct |
1583 ms |
61300 KB |
Output is correct |
35 |
Correct |
1037 ms |
63316 KB |
Output is correct |
36 |
Correct |
430 ms |
63060 KB |
Output is correct |
37 |
Correct |
352 ms |
60496 KB |
Output is correct |
38 |
Correct |
285 ms |
60244 KB |
Output is correct |
39 |
Correct |
245 ms |
59988 KB |
Output is correct |
40 |
Correct |
263 ms |
60184 KB |
Output is correct |
41 |
Correct |
377 ms |
60244 KB |
Output is correct |
42 |
Correct |
353 ms |
60244 KB |
Output is correct |
43 |
Correct |
143 ms |
7752 KB |
Output is correct |
44 |
Correct |
378 ms |
60500 KB |
Output is correct |
45 |
Correct |
356 ms |
60244 KB |
Output is correct |
46 |
Correct |
221 ms |
60244 KB |
Output is correct |
47 |
Correct |
186 ms |
58264 KB |
Output is correct |
48 |
Correct |
178 ms |
57880 KB |
Output is correct |
49 |
Correct |
215 ms |
58912 KB |
Output is correct |
50 |
Correct |
324 ms |
59760 KB |
Output is correct |
51 |
Correct |
202 ms |
58708 KB |
Output is correct |
52 |
Runtime error |
341 ms |
118748 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |