#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=1e6+4;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()
ll n,x,a[N],u[N];
vector<pll> v;
multiset<ll,greater<ll> > ans;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
REP1(i,n+1){cin>>x;v.pb(mp(x,i));}
sort(v.begin(),v.end());
REP1(i,n)cin>>u[i];
sort(u+1,u+n+1);
REP1(i,n){ans.insert(max(0LL,v[i].X-u[i]));}
a[v[0].Y]=*ans.begin();
REP1(i,n){
ans.erase(ans.find(max(0LL,v[i].X-u[i])));
ans.insert(max(0LL,v[i-1].X-u[i]));
a[v[i].Y]=*ans.begin();
}
REP1(i,n+1)cout<<a[i]<<(i==n+1?"\n":" ");
return 0;
}
# |
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 |
6 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 |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
504 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 |
556 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
8 ms |
508 KB |
Output is correct |
20 |
Correct |
6 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 |
6 ms |
508 KB |
Output is correct |
24 |
Correct |
6 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 |
504 KB |
Output is correct |
28 |
Correct |
6 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 |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
504 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 |
556 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
8 ms |
508 KB |
Output is correct |
20 |
Correct |
6 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 |
6 ms |
508 KB |
Output is correct |
24 |
Correct |
6 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 |
504 KB |
Output is correct |
28 |
Correct |
6 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 |
223 ms |
16736 KB |
Output is correct |
34 |
Correct |
244 ms |
17680 KB |
Output is correct |
35 |
Correct |
223 ms |
16864 KB |
Output is correct |
36 |
Correct |
258 ms |
17504 KB |
Output is correct |
37 |
Correct |
263 ms |
18020 KB |
Output is correct |
38 |
Correct |
241 ms |
17760 KB |
Output is correct |
39 |
Correct |
338 ms |
16736 KB |
Output is correct |
40 |
Correct |
324 ms |
16608 KB |
Output is correct |
41 |
Correct |
346 ms |
16992 KB |
Output is correct |
42 |
Correct |
345 ms |
16844 KB |
Output is correct |
43 |
Correct |
330 ms |
16736 KB |
Output is correct |
44 |
Correct |
240 ms |
16224 KB |
Output is correct |
45 |
Correct |
209 ms |
16352 KB |
Output is correct |
46 |
Correct |
210 ms |
16224 KB |
Output is correct |
47 |
Correct |
196 ms |
16608 KB |
Output is correct |
48 |
Correct |
212 ms |
16608 KB |
Output is correct |
49 |
Correct |
354 ms |
17368 KB |
Output is correct |
50 |
Correct |
342 ms |
17248 KB |
Output is correct |
51 |
Correct |
369 ms |
17376 KB |
Output is correct |
52 |
Correct |
344 ms |
17248 KB |
Output is correct |
53 |
Correct |
365 ms |
17376 KB |
Output is correct |