#include <iostream>
#include <set>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=100005;
multiset<int> s[1000];
multiset<int>::iterator it1;
struct event
{
int val,wh,mag,tip;
}ev[3*nmax];
int ans[nmax];
int n,k,q,i,j,x,t,a,b,nr,X,mn;
bool comp(event unu,event doi)
{
if(unu.val==doi.val) return unu.tip<doi.tip;
return unu.val<doi.val;
}
int main()
{
//freopen("data.in","r",stdin);
cin>>n>>k>>q;
for(i=1;i<=n;i++)
{
cin>>x>>t>>a>>b;
ev[++nr]={a,x,t,1};
ev[++nr]={b+1,x,t,-1};
}
for(i=1;i<=q;i++)
{
cin>>x>>t;
ev[++nr]={t,x,i,2};
}
sort(ev+1,ev+nr+1,comp);
for(i=1;i<=nr;i++)
{
if(ev[i].tip==1)
{
s[ev[i].mag].insert(ev[i].wh);
}
if(ev[i].tip==-1)
{
s[ev[i].mag].erase(s[ev[i].mag].lower_bound(ev[i].wh));
}
if(ev[i].tip==2)
{
X=ev[i].wh;
for(j=1;j<=k&&ans[ev[i].mag]!=-1;j++)
{
if(s[j].empty()) ans[ev[i].mag]=-1;
else
{
mn=1000*1000*100+1;
it1=s[j].lower_bound(X);
if(it1!=s[j].end()) mn=min(mn,(*it1)-X);
if(it1!=s[j].begin()) {it1--;mn=min(mn,X-(*it1));}
ans[ev[i].mag]=max(ans[ev[i].mag],mn);
}
}
}
}
for(i=1;i<=q;i++)
cout<<ans[i]<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
4 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
708 KB |
Output is correct |
8 |
Correct |
4 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
4 ms |
736 KB |
Output is correct |
11 |
Correct |
4 ms |
736 KB |
Output is correct |
12 |
Correct |
4 ms |
736 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
4 ms |
736 KB |
Output is correct |
15 |
Correct |
4 ms |
736 KB |
Output is correct |
16 |
Correct |
4 ms |
736 KB |
Output is correct |
17 |
Correct |
4 ms |
736 KB |
Output is correct |
18 |
Correct |
4 ms |
736 KB |
Output is correct |
19 |
Correct |
4 ms |
736 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
736 KB |
Output is correct |
22 |
Correct |
4 ms |
756 KB |
Output is correct |
23 |
Correct |
4 ms |
804 KB |
Output is correct |
24 |
Correct |
4 ms |
804 KB |
Output is correct |
25 |
Correct |
4 ms |
804 KB |
Output is correct |
26 |
Correct |
3 ms |
804 KB |
Output is correct |
27 |
Correct |
3 ms |
804 KB |
Output is correct |
28 |
Correct |
3 ms |
804 KB |
Output is correct |
29 |
Correct |
4 ms |
804 KB |
Output is correct |
30 |
Correct |
4 ms |
804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
4 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
708 KB |
Output is correct |
8 |
Correct |
4 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
4 ms |
736 KB |
Output is correct |
11 |
Correct |
4 ms |
736 KB |
Output is correct |
12 |
Correct |
4 ms |
736 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
4 ms |
736 KB |
Output is correct |
15 |
Correct |
4 ms |
736 KB |
Output is correct |
16 |
Correct |
4 ms |
736 KB |
Output is correct |
17 |
Correct |
4 ms |
736 KB |
Output is correct |
18 |
Correct |
4 ms |
736 KB |
Output is correct |
19 |
Correct |
4 ms |
736 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
736 KB |
Output is correct |
22 |
Correct |
4 ms |
756 KB |
Output is correct |
23 |
Correct |
4 ms |
804 KB |
Output is correct |
24 |
Correct |
4 ms |
804 KB |
Output is correct |
25 |
Correct |
4 ms |
804 KB |
Output is correct |
26 |
Correct |
3 ms |
804 KB |
Output is correct |
27 |
Correct |
3 ms |
804 KB |
Output is correct |
28 |
Correct |
3 ms |
804 KB |
Output is correct |
29 |
Correct |
4 ms |
804 KB |
Output is correct |
30 |
Correct |
4 ms |
804 KB |
Output is correct |
31 |
Correct |
3164 ms |
7112 KB |
Output is correct |
32 |
Correct |
155 ms |
7112 KB |
Output is correct |
33 |
Correct |
331 ms |
7112 KB |
Output is correct |
34 |
Correct |
2579 ms |
7112 KB |
Output is correct |
35 |
Correct |
1594 ms |
7112 KB |
Output is correct |
36 |
Correct |
402 ms |
7112 KB |
Output is correct |
37 |
Correct |
309 ms |
7112 KB |
Output is correct |
38 |
Correct |
229 ms |
7112 KB |
Output is correct |
39 |
Correct |
213 ms |
7112 KB |
Output is correct |
40 |
Correct |
212 ms |
7112 KB |
Output is correct |
41 |
Correct |
475 ms |
7112 KB |
Output is correct |
42 |
Correct |
434 ms |
7112 KB |
Output is correct |
43 |
Correct |
700 ms |
7228 KB |
Output is correct |
44 |
Correct |
424 ms |
7228 KB |
Output is correct |
45 |
Correct |
282 ms |
7228 KB |
Output is correct |
46 |
Correct |
216 ms |
7228 KB |
Output is correct |
47 |
Correct |
236 ms |
7228 KB |
Output is correct |
48 |
Correct |
195 ms |
7228 KB |
Output is correct |
49 |
Correct |
259 ms |
7228 KB |
Output is correct |
50 |
Correct |
445 ms |
7228 KB |
Output is correct |
51 |
Correct |
202 ms |
7228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
336 ms |
10500 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
269 ms |
10520 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
4 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
708 KB |
Output is correct |
8 |
Correct |
4 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
4 ms |
736 KB |
Output is correct |
11 |
Correct |
4 ms |
736 KB |
Output is correct |
12 |
Correct |
4 ms |
736 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
4 ms |
736 KB |
Output is correct |
15 |
Correct |
4 ms |
736 KB |
Output is correct |
16 |
Correct |
4 ms |
736 KB |
Output is correct |
17 |
Correct |
4 ms |
736 KB |
Output is correct |
18 |
Correct |
4 ms |
736 KB |
Output is correct |
19 |
Correct |
4 ms |
736 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
736 KB |
Output is correct |
22 |
Correct |
4 ms |
756 KB |
Output is correct |
23 |
Correct |
4 ms |
804 KB |
Output is correct |
24 |
Correct |
4 ms |
804 KB |
Output is correct |
25 |
Correct |
4 ms |
804 KB |
Output is correct |
26 |
Correct |
3 ms |
804 KB |
Output is correct |
27 |
Correct |
3 ms |
804 KB |
Output is correct |
28 |
Correct |
3 ms |
804 KB |
Output is correct |
29 |
Correct |
4 ms |
804 KB |
Output is correct |
30 |
Correct |
4 ms |
804 KB |
Output is correct |
31 |
Correct |
3164 ms |
7112 KB |
Output is correct |
32 |
Correct |
155 ms |
7112 KB |
Output is correct |
33 |
Correct |
331 ms |
7112 KB |
Output is correct |
34 |
Correct |
2579 ms |
7112 KB |
Output is correct |
35 |
Correct |
1594 ms |
7112 KB |
Output is correct |
36 |
Correct |
402 ms |
7112 KB |
Output is correct |
37 |
Correct |
309 ms |
7112 KB |
Output is correct |
38 |
Correct |
229 ms |
7112 KB |
Output is correct |
39 |
Correct |
213 ms |
7112 KB |
Output is correct |
40 |
Correct |
212 ms |
7112 KB |
Output is correct |
41 |
Correct |
475 ms |
7112 KB |
Output is correct |
42 |
Correct |
434 ms |
7112 KB |
Output is correct |
43 |
Correct |
700 ms |
7228 KB |
Output is correct |
44 |
Correct |
424 ms |
7228 KB |
Output is correct |
45 |
Correct |
282 ms |
7228 KB |
Output is correct |
46 |
Correct |
216 ms |
7228 KB |
Output is correct |
47 |
Correct |
236 ms |
7228 KB |
Output is correct |
48 |
Correct |
195 ms |
7228 KB |
Output is correct |
49 |
Correct |
259 ms |
7228 KB |
Output is correct |
50 |
Correct |
445 ms |
7228 KB |
Output is correct |
51 |
Correct |
202 ms |
7228 KB |
Output is correct |
52 |
Runtime error |
198 ms |
10520 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
4 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
708 KB |
Output is correct |
8 |
Correct |
4 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
4 ms |
736 KB |
Output is correct |
11 |
Correct |
4 ms |
736 KB |
Output is correct |
12 |
Correct |
4 ms |
736 KB |
Output is correct |
13 |
Correct |
3 ms |
736 KB |
Output is correct |
14 |
Correct |
4 ms |
736 KB |
Output is correct |
15 |
Correct |
4 ms |
736 KB |
Output is correct |
16 |
Correct |
4 ms |
736 KB |
Output is correct |
17 |
Correct |
4 ms |
736 KB |
Output is correct |
18 |
Correct |
4 ms |
736 KB |
Output is correct |
19 |
Correct |
4 ms |
736 KB |
Output is correct |
20 |
Correct |
4 ms |
736 KB |
Output is correct |
21 |
Correct |
5 ms |
736 KB |
Output is correct |
22 |
Correct |
4 ms |
756 KB |
Output is correct |
23 |
Correct |
4 ms |
804 KB |
Output is correct |
24 |
Correct |
4 ms |
804 KB |
Output is correct |
25 |
Correct |
4 ms |
804 KB |
Output is correct |
26 |
Correct |
3 ms |
804 KB |
Output is correct |
27 |
Correct |
3 ms |
804 KB |
Output is correct |
28 |
Correct |
3 ms |
804 KB |
Output is correct |
29 |
Correct |
4 ms |
804 KB |
Output is correct |
30 |
Correct |
4 ms |
804 KB |
Output is correct |
31 |
Correct |
3164 ms |
7112 KB |
Output is correct |
32 |
Correct |
155 ms |
7112 KB |
Output is correct |
33 |
Correct |
331 ms |
7112 KB |
Output is correct |
34 |
Correct |
2579 ms |
7112 KB |
Output is correct |
35 |
Correct |
1594 ms |
7112 KB |
Output is correct |
36 |
Correct |
402 ms |
7112 KB |
Output is correct |
37 |
Correct |
309 ms |
7112 KB |
Output is correct |
38 |
Correct |
229 ms |
7112 KB |
Output is correct |
39 |
Correct |
213 ms |
7112 KB |
Output is correct |
40 |
Correct |
212 ms |
7112 KB |
Output is correct |
41 |
Correct |
475 ms |
7112 KB |
Output is correct |
42 |
Correct |
434 ms |
7112 KB |
Output is correct |
43 |
Correct |
700 ms |
7228 KB |
Output is correct |
44 |
Correct |
424 ms |
7228 KB |
Output is correct |
45 |
Correct |
282 ms |
7228 KB |
Output is correct |
46 |
Correct |
216 ms |
7228 KB |
Output is correct |
47 |
Correct |
236 ms |
7228 KB |
Output is correct |
48 |
Correct |
195 ms |
7228 KB |
Output is correct |
49 |
Correct |
259 ms |
7228 KB |
Output is correct |
50 |
Correct |
445 ms |
7228 KB |
Output is correct |
51 |
Correct |
202 ms |
7228 KB |
Output is correct |
52 |
Runtime error |
336 ms |
10500 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |