#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define ff first
#define ss second
#define N 200002
#define MOD 1000000007
int a[N], ans[N];
vector<pair<int, int> > ne;
multiset<int> in;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i = 0; i <= n; ++i){
int k;
cin>>k;
ne.push_back({k, i});
}
sort(ne.begin(), ne.end());
for(int i = 0; i < n; ++i){
cin>>a[i];
}
sort(a, a + n);
for(int i = 0; i < n; ++i)
in.insert(a[i] - ne[i].ff);
ans[ne[n].ss] = *in.begin();
for(int i = n - 1; i >= 0; --i){
in.erase(in.find(a[i] - ne[i].ff));
in.insert(a[i] - ne[i + 1].ff);
ans[ne[i].ss] = *in.begin();
}
for(int i = 0; i <= n; ++i)
cout<<max(0, -ans[i])<<' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
380 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
380 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
504 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
6 ms |
504 KB |
Output is correct |
18 |
Correct |
6 ms |
504 KB |
Output is correct |
19 |
Correct |
6 ms |
504 KB |
Output is correct |
20 |
Correct |
6 ms |
504 KB |
Output is correct |
21 |
Correct |
7 ms |
504 KB |
Output is correct |
22 |
Correct |
6 ms |
504 KB |
Output is correct |
23 |
Correct |
6 ms |
504 KB |
Output is correct |
24 |
Correct |
6 ms |
504 KB |
Output is correct |
25 |
Correct |
6 ms |
504 KB |
Output is correct |
26 |
Correct |
6 ms |
504 KB |
Output is correct |
27 |
Correct |
7 ms |
504 KB |
Output is correct |
28 |
Correct |
6 ms |
504 KB |
Output is correct |
29 |
Correct |
6 ms |
504 KB |
Output is correct |
30 |
Correct |
6 ms |
504 KB |
Output is correct |
31 |
Correct |
7 ms |
508 KB |
Output is correct |
32 |
Correct |
7 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
508 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
380 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
6 ms |
504 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
6 ms |
504 KB |
Output is correct |
18 |
Correct |
6 ms |
504 KB |
Output is correct |
19 |
Correct |
6 ms |
504 KB |
Output is correct |
20 |
Correct |
6 ms |
504 KB |
Output is correct |
21 |
Correct |
7 ms |
504 KB |
Output is correct |
22 |
Correct |
6 ms |
504 KB |
Output is correct |
23 |
Correct |
6 ms |
504 KB |
Output is correct |
24 |
Correct |
6 ms |
504 KB |
Output is correct |
25 |
Correct |
6 ms |
504 KB |
Output is correct |
26 |
Correct |
6 ms |
504 KB |
Output is correct |
27 |
Correct |
7 ms |
504 KB |
Output is correct |
28 |
Correct |
6 ms |
504 KB |
Output is correct |
29 |
Correct |
6 ms |
504 KB |
Output is correct |
30 |
Correct |
6 ms |
504 KB |
Output is correct |
31 |
Correct |
7 ms |
508 KB |
Output is correct |
32 |
Correct |
7 ms |
504 KB |
Output is correct |
33 |
Correct |
241 ms |
13776 KB |
Output is correct |
34 |
Correct |
252 ms |
14384 KB |
Output is correct |
35 |
Correct |
236 ms |
14060 KB |
Output is correct |
36 |
Correct |
252 ms |
14512 KB |
Output is correct |
37 |
Correct |
248 ms |
14828 KB |
Output is correct |
38 |
Correct |
242 ms |
14696 KB |
Output is correct |
39 |
Correct |
290 ms |
13672 KB |
Output is correct |
40 |
Correct |
297 ms |
13672 KB |
Output is correct |
41 |
Correct |
290 ms |
13800 KB |
Output is correct |
42 |
Correct |
306 ms |
13792 KB |
Output is correct |
43 |
Correct |
283 ms |
13672 KB |
Output is correct |
44 |
Correct |
268 ms |
13160 KB |
Output is correct |
45 |
Correct |
274 ms |
13416 KB |
Output is correct |
46 |
Correct |
267 ms |
13164 KB |
Output is correct |
47 |
Correct |
194 ms |
13544 KB |
Output is correct |
48 |
Correct |
194 ms |
13560 KB |
Output is correct |
49 |
Correct |
306 ms |
14056 KB |
Output is correct |
50 |
Correct |
297 ms |
14060 KB |
Output is correct |
51 |
Correct |
303 ms |
14056 KB |
Output is correct |
52 |
Correct |
305 ms |
14052 KB |
Output is correct |
53 |
Correct |
303 ms |
14132 KB |
Output is correct |