#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
#define int long long
using namespace std;
signed main(){
AquA;
int n;
cin >> n;
vector<pair<int,int> > v(n+1);
vector<int> b(n);
for(int i=0;i<=n;i++){
cin >> v[i].fs;
v[i].sc=i;
}
for(int i=0;i<n;i++){
cin >> b[i];
}
sort(b.begin(),b.end());
sort(v.begin(),v.end());
vector<int> ans(n+1);
multiset<int,greater<int> > m;
for(int i=0;i<n;i++){
m.insert(max(v[i+1].fs-b[i],0ll));
}
for(int i=0;i<=n;i++){
ans[v[i].sc]=*m.begin();
if(i!=n){
m.erase(m.find(max(v[i+1].fs-b[i],0ll)));
m.insert(max(v[i].fs-b[i],0ll));
}
}
for(int i=0;i<=n;i++){
cout << ans[i] << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
2 ms |
448 KB |
Output is correct |
18 |
Correct |
2 ms |
460 KB |
Output is correct |
19 |
Correct |
2 ms |
460 KB |
Output is correct |
20 |
Correct |
2 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
452 KB |
Output is correct |
22 |
Correct |
2 ms |
456 KB |
Output is correct |
23 |
Correct |
2 ms |
452 KB |
Output is correct |
24 |
Correct |
2 ms |
460 KB |
Output is correct |
25 |
Correct |
2 ms |
452 KB |
Output is correct |
26 |
Correct |
2 ms |
460 KB |
Output is correct |
27 |
Correct |
2 ms |
460 KB |
Output is correct |
28 |
Correct |
2 ms |
460 KB |
Output is correct |
29 |
Correct |
1 ms |
452 KB |
Output is correct |
30 |
Correct |
1 ms |
460 KB |
Output is correct |
31 |
Correct |
1 ms |
460 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
316 KB |
Output is correct |
17 |
Correct |
2 ms |
448 KB |
Output is correct |
18 |
Correct |
2 ms |
460 KB |
Output is correct |
19 |
Correct |
2 ms |
460 KB |
Output is correct |
20 |
Correct |
2 ms |
460 KB |
Output is correct |
21 |
Correct |
2 ms |
452 KB |
Output is correct |
22 |
Correct |
2 ms |
456 KB |
Output is correct |
23 |
Correct |
2 ms |
452 KB |
Output is correct |
24 |
Correct |
2 ms |
460 KB |
Output is correct |
25 |
Correct |
2 ms |
452 KB |
Output is correct |
26 |
Correct |
2 ms |
460 KB |
Output is correct |
27 |
Correct |
2 ms |
460 KB |
Output is correct |
28 |
Correct |
2 ms |
460 KB |
Output is correct |
29 |
Correct |
1 ms |
452 KB |
Output is correct |
30 |
Correct |
1 ms |
460 KB |
Output is correct |
31 |
Correct |
1 ms |
460 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
228 ms |
20308 KB |
Output is correct |
34 |
Correct |
191 ms |
21272 KB |
Output is correct |
35 |
Correct |
187 ms |
20548 KB |
Output is correct |
36 |
Correct |
195 ms |
21128 KB |
Output is correct |
37 |
Correct |
200 ms |
21700 KB |
Output is correct |
38 |
Correct |
186 ms |
21556 KB |
Output is correct |
39 |
Correct |
277 ms |
20440 KB |
Output is correct |
40 |
Correct |
232 ms |
20248 KB |
Output is correct |
41 |
Correct |
242 ms |
20524 KB |
Output is correct |
42 |
Correct |
265 ms |
20500 KB |
Output is correct |
43 |
Correct |
258 ms |
20332 KB |
Output is correct |
44 |
Correct |
190 ms |
19780 KB |
Output is correct |
45 |
Correct |
169 ms |
19912 KB |
Output is correct |
46 |
Correct |
186 ms |
19780 KB |
Output is correct |
47 |
Correct |
161 ms |
20348 KB |
Output is correct |
48 |
Correct |
203 ms |
20364 KB |
Output is correct |
49 |
Correct |
275 ms |
20984 KB |
Output is correct |
50 |
Correct |
253 ms |
20932 KB |
Output is correct |
51 |
Correct |
295 ms |
20992 KB |
Output is correct |
52 |
Correct |
258 ms |
20992 KB |
Output is correct |
53 |
Correct |
255 ms |
20992 KB |
Output is correct |