# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
521781 |
2022-02-03T06:13:27 Z |
CSQ31 |
New Home (APIO18_new_home) |
C++17 |
|
5000 ms |
42656 KB |
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5+5;
int x[MAXN],t[MAXN];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
int n,q,k;
cin>>n>>k>>q;
vector<multiset<int>>store(k+1);
vector<array<int,2>>s;
for(int i=1;i<=n;i++){
int a,b;
cin>>x[i]>>t[i]>>a>>b;
s.push_back({a,-i});
s.push_back({b+1,i});
}
sort(s.begin(),s.end());
vector<int>l(q),y(q),id(q);
vector<int>ans(q,0);
for(int i=0;i<q;i++){
cin>>l[i]>>y[i];
id[i] = i;
}
sort(id.begin(),id.end(),[&](const int &i,const int &j){return y[j] > y[i];});
int ptr = -1;
for(int i=0;i<q;i++){
while(ptr+1<2*n && s[ptr+1][0] <= y[id[i]]){
ptr++;
int j = s[ptr][1];
//cout<<i<<" "<<j<<'\n';
if(j < 0)store[t[-j]].insert(x[-j]);
else store[t[j]].erase(store[t[j]].find(x[j]));
}
for(int j=1;j<=k;j++){
int c = 1e9;
auto it = store[j].lower_bound(l[id[i]]);
if(it != store[j].end())c = min(c,*it-l[id[i]]);
if(it != store[j].begin()){
it--;
c = min(c,l[id[i]] - *it);
}
ans[id[i]] = max(ans[id[i]],c);
}
if(ans[id[i]] == 1e9)ans[id[i]] = -1;
}
for(int i=0;i<q;i++)cout<<ans[i]<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
368 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
368 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1784 ms |
8868 KB |
Output is correct |
32 |
Correct |
89 ms |
5056 KB |
Output is correct |
33 |
Correct |
144 ms |
6884 KB |
Output is correct |
34 |
Correct |
1384 ms |
7108 KB |
Output is correct |
35 |
Correct |
783 ms |
8840 KB |
Output is correct |
36 |
Correct |
166 ms |
8768 KB |
Output is correct |
37 |
Correct |
142 ms |
6208 KB |
Output is correct |
38 |
Correct |
81 ms |
6076 KB |
Output is correct |
39 |
Correct |
70 ms |
5884 KB |
Output is correct |
40 |
Correct |
70 ms |
5880 KB |
Output is correct |
41 |
Correct |
251 ms |
6196 KB |
Output is correct |
42 |
Correct |
322 ms |
5936 KB |
Output is correct |
43 |
Correct |
216 ms |
8564 KB |
Output is correct |
44 |
Correct |
200 ms |
6076 KB |
Output is correct |
45 |
Correct |
100 ms |
6084 KB |
Output is correct |
46 |
Correct |
59 ms |
5984 KB |
Output is correct |
47 |
Correct |
56 ms |
5624 KB |
Output is correct |
48 |
Correct |
51 ms |
5564 KB |
Output is correct |
49 |
Correct |
66 ms |
5748 KB |
Output is correct |
50 |
Correct |
186 ms |
5820 KB |
Output is correct |
51 |
Correct |
58 ms |
5732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5035 ms |
42656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5046 ms |
39336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
368 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1784 ms |
8868 KB |
Output is correct |
32 |
Correct |
89 ms |
5056 KB |
Output is correct |
33 |
Correct |
144 ms |
6884 KB |
Output is correct |
34 |
Correct |
1384 ms |
7108 KB |
Output is correct |
35 |
Correct |
783 ms |
8840 KB |
Output is correct |
36 |
Correct |
166 ms |
8768 KB |
Output is correct |
37 |
Correct |
142 ms |
6208 KB |
Output is correct |
38 |
Correct |
81 ms |
6076 KB |
Output is correct |
39 |
Correct |
70 ms |
5884 KB |
Output is correct |
40 |
Correct |
70 ms |
5880 KB |
Output is correct |
41 |
Correct |
251 ms |
6196 KB |
Output is correct |
42 |
Correct |
322 ms |
5936 KB |
Output is correct |
43 |
Correct |
216 ms |
8564 KB |
Output is correct |
44 |
Correct |
200 ms |
6076 KB |
Output is correct |
45 |
Correct |
100 ms |
6084 KB |
Output is correct |
46 |
Correct |
59 ms |
5984 KB |
Output is correct |
47 |
Correct |
56 ms |
5624 KB |
Output is correct |
48 |
Correct |
51 ms |
5564 KB |
Output is correct |
49 |
Correct |
66 ms |
5748 KB |
Output is correct |
50 |
Correct |
186 ms |
5820 KB |
Output is correct |
51 |
Correct |
58 ms |
5732 KB |
Output is correct |
52 |
Execution timed out |
5102 ms |
9704 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
368 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
2 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1784 ms |
8868 KB |
Output is correct |
32 |
Correct |
89 ms |
5056 KB |
Output is correct |
33 |
Correct |
144 ms |
6884 KB |
Output is correct |
34 |
Correct |
1384 ms |
7108 KB |
Output is correct |
35 |
Correct |
783 ms |
8840 KB |
Output is correct |
36 |
Correct |
166 ms |
8768 KB |
Output is correct |
37 |
Correct |
142 ms |
6208 KB |
Output is correct |
38 |
Correct |
81 ms |
6076 KB |
Output is correct |
39 |
Correct |
70 ms |
5884 KB |
Output is correct |
40 |
Correct |
70 ms |
5880 KB |
Output is correct |
41 |
Correct |
251 ms |
6196 KB |
Output is correct |
42 |
Correct |
322 ms |
5936 KB |
Output is correct |
43 |
Correct |
216 ms |
8564 KB |
Output is correct |
44 |
Correct |
200 ms |
6076 KB |
Output is correct |
45 |
Correct |
100 ms |
6084 KB |
Output is correct |
46 |
Correct |
59 ms |
5984 KB |
Output is correct |
47 |
Correct |
56 ms |
5624 KB |
Output is correct |
48 |
Correct |
51 ms |
5564 KB |
Output is correct |
49 |
Correct |
66 ms |
5748 KB |
Output is correct |
50 |
Correct |
186 ms |
5820 KB |
Output is correct |
51 |
Correct |
58 ms |
5732 KB |
Output is correct |
52 |
Execution timed out |
5035 ms |
42656 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |