#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("q.gir","r",stdin);
// freopen("q.cik","w",stdout);
int n;
cin >> n;
vector<ii> W;
vector<int> arr;
map<int,int> data;
vector<int> ans(n + 1, INF);
for(int i = 0; i <= n; i++){
int x;
cin >> x;
W.pb({x, i});
}
for(int i = 0; i < n; i++){
int x;
cin >> x;
arr.pb(x);
}
sort(all(W));
sort(all(arr));
for(int i = 1; i <= n; i++){
data[W[i].first - arr[i - 1]]++;
}
ans[W[0].second] = data.rbegin()->first;
for(int i = 1; i <= n; i++){
if(--data[W[i].first - arr[i - 1]] == 0)data.erase(W[i].first - arr[i - 1]);
data[W[i - 1].first - arr[i - 1]]++;
ans[W[i].second] = data.rbegin()->first;
}
for(int i = 0; i <= n; i++)cout << max(0ll, ans[i]) << "\n";
}
# |
Verdict |
Execution time |
Memory |
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 |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 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 |
6 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 |
7 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
6 ms |
528 KB |
Output is correct |
20 |
Correct |
7 ms |
504 KB |
Output is correct |
21 |
Correct |
6 ms |
504 KB |
Output is correct |
22 |
Correct |
6 ms |
504 KB |
Output is correct |
23 |
Correct |
7 ms |
504 KB |
Output is correct |
24 |
Correct |
7 ms |
504 KB |
Output is correct |
25 |
Correct |
6 ms |
508 KB |
Output is correct |
26 |
Correct |
6 ms |
504 KB |
Output is correct |
27 |
Correct |
6 ms |
508 KB |
Output is correct |
28 |
Correct |
7 ms |
632 KB |
Output is correct |
29 |
Correct |
6 ms |
504 KB |
Output is correct |
30 |
Correct |
6 ms |
504 KB |
Output is correct |
31 |
Correct |
6 ms |
504 KB |
Output is correct |
32 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 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 |
6 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 |
7 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
6 ms |
528 KB |
Output is correct |
20 |
Correct |
7 ms |
504 KB |
Output is correct |
21 |
Correct |
6 ms |
504 KB |
Output is correct |
22 |
Correct |
6 ms |
504 KB |
Output is correct |
23 |
Correct |
7 ms |
504 KB |
Output is correct |
24 |
Correct |
7 ms |
504 KB |
Output is correct |
25 |
Correct |
6 ms |
508 KB |
Output is correct |
26 |
Correct |
6 ms |
504 KB |
Output is correct |
27 |
Correct |
6 ms |
508 KB |
Output is correct |
28 |
Correct |
7 ms |
632 KB |
Output is correct |
29 |
Correct |
6 ms |
504 KB |
Output is correct |
30 |
Correct |
6 ms |
504 KB |
Output is correct |
31 |
Correct |
6 ms |
504 KB |
Output is correct |
32 |
Correct |
6 ms |
504 KB |
Output is correct |
33 |
Correct |
301 ms |
19428 KB |
Output is correct |
34 |
Correct |
313 ms |
20196 KB |
Output is correct |
35 |
Correct |
295 ms |
19712 KB |
Output is correct |
36 |
Correct |
289 ms |
19684 KB |
Output is correct |
37 |
Correct |
309 ms |
20324 KB |
Output is correct |
38 |
Correct |
307 ms |
20324 KB |
Output is correct |
39 |
Correct |
187 ms |
9700 KB |
Output is correct |
40 |
Correct |
195 ms |
9700 KB |
Output is correct |
41 |
Correct |
189 ms |
9700 KB |
Output is correct |
42 |
Correct |
193 ms |
9700 KB |
Output is correct |
43 |
Correct |
201 ms |
9680 KB |
Output is correct |
44 |
Correct |
143 ms |
9320 KB |
Output is correct |
45 |
Correct |
154 ms |
9316 KB |
Output is correct |
46 |
Correct |
148 ms |
9420 KB |
Output is correct |
47 |
Correct |
146 ms |
9700 KB |
Output is correct |
48 |
Correct |
148 ms |
9700 KB |
Output is correct |
49 |
Correct |
195 ms |
9892 KB |
Output is correct |
50 |
Correct |
190 ms |
9828 KB |
Output is correct |
51 |
Correct |
191 ms |
9828 KB |
Output is correct |
52 |
Correct |
188 ms |
9828 KB |
Output is correct |
53 |
Correct |
188 ms |
9828 KB |
Output is correct |