#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e5;
const int INF=1e12;
multiset<int> st[500];
multiset<int> itr it;
vector< pair<int,pii> > vec;
struct node
{
int pos,type,start,end;
} arr[MAX];
int N,K,Q,ind,lol,loc[MAX],year[MAX],res[MAX];
signed main()
{
ios_base::sync_with_stdio(false);
/*cin.tie(0);
cout.tie(0);*/
cin>>N>>K>>Q;
for(int A=1;A<=N;A++)
{
cin>>arr[A].pos>>arr[A].type>>arr[A].start>>arr[A].end;
vec.pb(mp(arr[A].start,mp(0,A)));
vec.pb(mp(arr[A].end,mp(2,A)));
}
for(int A=1;A<=Q;A++)
{
cin>>loc[A]>>year[A];
vec.pb(mp(year[A],mp(1,A)));
}
sort(vec.begin(),vec.end());
for(auto A:vec)
{
ind=A.second.second;
if(A.second.first==0)
st[arr[ind].type].insert(arr[ind].pos);
else if(A.second.first==1)
{
for(int B=1;B<=K;B++)
{
if(st[B].empty())
{
res[ind]=-1;
break;
}
else
{
lol=INF;
it=st[B].lower_bound(loc[ind]);
if(it!=st[B].end())
lol=min(lol,abs(loc[ind]-*it));
if((it--)!=st[B].begin())
lol=min(lol,abs(loc[ind]-*it));
res[ind]=max(res[ind],lol);
}
}
}
else
st[arr[ind].type].erase(st[arr[ind].type].find(arr[ind].pos));
}
for(int A=1;A<=Q;A++)
cout<<res[A]<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
776 KB |
Output is correct |
6 |
Correct |
2 ms |
776 KB |
Output is correct |
7 |
Correct |
2 ms |
780 KB |
Output is correct |
8 |
Correct |
3 ms |
816 KB |
Output is correct |
9 |
Correct |
3 ms |
836 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
3 ms |
916 KB |
Output is correct |
12 |
Correct |
3 ms |
932 KB |
Output is correct |
13 |
Correct |
3 ms |
952 KB |
Output is correct |
14 |
Correct |
2 ms |
952 KB |
Output is correct |
15 |
Correct |
3 ms |
956 KB |
Output is correct |
16 |
Correct |
3 ms |
956 KB |
Output is correct |
17 |
Correct |
3 ms |
956 KB |
Output is correct |
18 |
Correct |
3 ms |
956 KB |
Output is correct |
19 |
Correct |
3 ms |
956 KB |
Output is correct |
20 |
Correct |
3 ms |
956 KB |
Output is correct |
21 |
Correct |
4 ms |
956 KB |
Output is correct |
22 |
Correct |
3 ms |
956 KB |
Output is correct |
23 |
Correct |
3 ms |
956 KB |
Output is correct |
24 |
Correct |
3 ms |
972 KB |
Output is correct |
25 |
Correct |
3 ms |
972 KB |
Output is correct |
26 |
Correct |
3 ms |
972 KB |
Output is correct |
27 |
Correct |
3 ms |
972 KB |
Output is correct |
28 |
Correct |
3 ms |
972 KB |
Output is correct |
29 |
Correct |
3 ms |
972 KB |
Output is correct |
30 |
Correct |
2 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
776 KB |
Output is correct |
6 |
Correct |
2 ms |
776 KB |
Output is correct |
7 |
Correct |
2 ms |
780 KB |
Output is correct |
8 |
Correct |
3 ms |
816 KB |
Output is correct |
9 |
Correct |
3 ms |
836 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
3 ms |
916 KB |
Output is correct |
12 |
Correct |
3 ms |
932 KB |
Output is correct |
13 |
Correct |
3 ms |
952 KB |
Output is correct |
14 |
Correct |
2 ms |
952 KB |
Output is correct |
15 |
Correct |
3 ms |
956 KB |
Output is correct |
16 |
Correct |
3 ms |
956 KB |
Output is correct |
17 |
Correct |
3 ms |
956 KB |
Output is correct |
18 |
Correct |
3 ms |
956 KB |
Output is correct |
19 |
Correct |
3 ms |
956 KB |
Output is correct |
20 |
Correct |
3 ms |
956 KB |
Output is correct |
21 |
Correct |
4 ms |
956 KB |
Output is correct |
22 |
Correct |
3 ms |
956 KB |
Output is correct |
23 |
Correct |
3 ms |
956 KB |
Output is correct |
24 |
Correct |
3 ms |
972 KB |
Output is correct |
25 |
Correct |
3 ms |
972 KB |
Output is correct |
26 |
Correct |
3 ms |
972 KB |
Output is correct |
27 |
Correct |
3 ms |
972 KB |
Output is correct |
28 |
Correct |
3 ms |
972 KB |
Output is correct |
29 |
Correct |
3 ms |
972 KB |
Output is correct |
30 |
Correct |
2 ms |
972 KB |
Output is correct |
31 |
Correct |
3350 ms |
14752 KB |
Output is correct |
32 |
Correct |
144 ms |
14752 KB |
Output is correct |
33 |
Correct |
246 ms |
16524 KB |
Output is correct |
34 |
Correct |
2443 ms |
19888 KB |
Output is correct |
35 |
Correct |
1513 ms |
24312 KB |
Output is correct |
36 |
Correct |
299 ms |
27040 KB |
Output is correct |
37 |
Correct |
212 ms |
27352 KB |
Output is correct |
38 |
Correct |
129 ms |
30240 KB |
Output is correct |
39 |
Correct |
108 ms |
32956 KB |
Output is correct |
40 |
Correct |
106 ms |
35796 KB |
Output is correct |
41 |
Correct |
351 ms |
38996 KB |
Output is correct |
42 |
Correct |
275 ms |
41708 KB |
Output is correct |
43 |
Correct |
662 ms |
46984 KB |
Output is correct |
44 |
Correct |
290 ms |
47120 KB |
Output is correct |
45 |
Correct |
162 ms |
50252 KB |
Output is correct |
46 |
Correct |
97 ms |
52828 KB |
Output is correct |
47 |
Correct |
88 ms |
55164 KB |
Output is correct |
48 |
Correct |
88 ms |
57936 KB |
Output is correct |
49 |
Correct |
109 ms |
60884 KB |
Output is correct |
50 |
Correct |
245 ms |
63972 KB |
Output is correct |
51 |
Correct |
94 ms |
66776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
68 ms |
74868 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
64 ms |
75160 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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
776 KB |
Output is correct |
6 |
Correct |
2 ms |
776 KB |
Output is correct |
7 |
Correct |
2 ms |
780 KB |
Output is correct |
8 |
Correct |
3 ms |
816 KB |
Output is correct |
9 |
Correct |
3 ms |
836 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
3 ms |
916 KB |
Output is correct |
12 |
Correct |
3 ms |
932 KB |
Output is correct |
13 |
Correct |
3 ms |
952 KB |
Output is correct |
14 |
Correct |
2 ms |
952 KB |
Output is correct |
15 |
Correct |
3 ms |
956 KB |
Output is correct |
16 |
Correct |
3 ms |
956 KB |
Output is correct |
17 |
Correct |
3 ms |
956 KB |
Output is correct |
18 |
Correct |
3 ms |
956 KB |
Output is correct |
19 |
Correct |
3 ms |
956 KB |
Output is correct |
20 |
Correct |
3 ms |
956 KB |
Output is correct |
21 |
Correct |
4 ms |
956 KB |
Output is correct |
22 |
Correct |
3 ms |
956 KB |
Output is correct |
23 |
Correct |
3 ms |
956 KB |
Output is correct |
24 |
Correct |
3 ms |
972 KB |
Output is correct |
25 |
Correct |
3 ms |
972 KB |
Output is correct |
26 |
Correct |
3 ms |
972 KB |
Output is correct |
27 |
Correct |
3 ms |
972 KB |
Output is correct |
28 |
Correct |
3 ms |
972 KB |
Output is correct |
29 |
Correct |
3 ms |
972 KB |
Output is correct |
30 |
Correct |
2 ms |
972 KB |
Output is correct |
31 |
Correct |
3350 ms |
14752 KB |
Output is correct |
32 |
Correct |
144 ms |
14752 KB |
Output is correct |
33 |
Correct |
246 ms |
16524 KB |
Output is correct |
34 |
Correct |
2443 ms |
19888 KB |
Output is correct |
35 |
Correct |
1513 ms |
24312 KB |
Output is correct |
36 |
Correct |
299 ms |
27040 KB |
Output is correct |
37 |
Correct |
212 ms |
27352 KB |
Output is correct |
38 |
Correct |
129 ms |
30240 KB |
Output is correct |
39 |
Correct |
108 ms |
32956 KB |
Output is correct |
40 |
Correct |
106 ms |
35796 KB |
Output is correct |
41 |
Correct |
351 ms |
38996 KB |
Output is correct |
42 |
Correct |
275 ms |
41708 KB |
Output is correct |
43 |
Correct |
662 ms |
46984 KB |
Output is correct |
44 |
Correct |
290 ms |
47120 KB |
Output is correct |
45 |
Correct |
162 ms |
50252 KB |
Output is correct |
46 |
Correct |
97 ms |
52828 KB |
Output is correct |
47 |
Correct |
88 ms |
55164 KB |
Output is correct |
48 |
Correct |
88 ms |
57936 KB |
Output is correct |
49 |
Correct |
109 ms |
60884 KB |
Output is correct |
50 |
Correct |
245 ms |
63972 KB |
Output is correct |
51 |
Correct |
94 ms |
66776 KB |
Output is correct |
52 |
Runtime error |
92 ms |
77616 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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
568 KB |
Output is correct |
4 |
Correct |
2 ms |
568 KB |
Output is correct |
5 |
Correct |
2 ms |
776 KB |
Output is correct |
6 |
Correct |
2 ms |
776 KB |
Output is correct |
7 |
Correct |
2 ms |
780 KB |
Output is correct |
8 |
Correct |
3 ms |
816 KB |
Output is correct |
9 |
Correct |
3 ms |
836 KB |
Output is correct |
10 |
Correct |
3 ms |
876 KB |
Output is correct |
11 |
Correct |
3 ms |
916 KB |
Output is correct |
12 |
Correct |
3 ms |
932 KB |
Output is correct |
13 |
Correct |
3 ms |
952 KB |
Output is correct |
14 |
Correct |
2 ms |
952 KB |
Output is correct |
15 |
Correct |
3 ms |
956 KB |
Output is correct |
16 |
Correct |
3 ms |
956 KB |
Output is correct |
17 |
Correct |
3 ms |
956 KB |
Output is correct |
18 |
Correct |
3 ms |
956 KB |
Output is correct |
19 |
Correct |
3 ms |
956 KB |
Output is correct |
20 |
Correct |
3 ms |
956 KB |
Output is correct |
21 |
Correct |
4 ms |
956 KB |
Output is correct |
22 |
Correct |
3 ms |
956 KB |
Output is correct |
23 |
Correct |
3 ms |
956 KB |
Output is correct |
24 |
Correct |
3 ms |
972 KB |
Output is correct |
25 |
Correct |
3 ms |
972 KB |
Output is correct |
26 |
Correct |
3 ms |
972 KB |
Output is correct |
27 |
Correct |
3 ms |
972 KB |
Output is correct |
28 |
Correct |
3 ms |
972 KB |
Output is correct |
29 |
Correct |
3 ms |
972 KB |
Output is correct |
30 |
Correct |
2 ms |
972 KB |
Output is correct |
31 |
Correct |
3350 ms |
14752 KB |
Output is correct |
32 |
Correct |
144 ms |
14752 KB |
Output is correct |
33 |
Correct |
246 ms |
16524 KB |
Output is correct |
34 |
Correct |
2443 ms |
19888 KB |
Output is correct |
35 |
Correct |
1513 ms |
24312 KB |
Output is correct |
36 |
Correct |
299 ms |
27040 KB |
Output is correct |
37 |
Correct |
212 ms |
27352 KB |
Output is correct |
38 |
Correct |
129 ms |
30240 KB |
Output is correct |
39 |
Correct |
108 ms |
32956 KB |
Output is correct |
40 |
Correct |
106 ms |
35796 KB |
Output is correct |
41 |
Correct |
351 ms |
38996 KB |
Output is correct |
42 |
Correct |
275 ms |
41708 KB |
Output is correct |
43 |
Correct |
662 ms |
46984 KB |
Output is correct |
44 |
Correct |
290 ms |
47120 KB |
Output is correct |
45 |
Correct |
162 ms |
50252 KB |
Output is correct |
46 |
Correct |
97 ms |
52828 KB |
Output is correct |
47 |
Correct |
88 ms |
55164 KB |
Output is correct |
48 |
Correct |
88 ms |
57936 KB |
Output is correct |
49 |
Correct |
109 ms |
60884 KB |
Output is correct |
50 |
Correct |
245 ms |
63972 KB |
Output is correct |
51 |
Correct |
94 ms |
66776 KB |
Output is correct |
52 |
Runtime error |
68 ms |
74868 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |