Submission #925438

# Submission time Handle Problem Language Result Execution time Memory
925438 2024-02-11T15:54:30 Z Xiaoyang Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
79 ms 16464 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 1ll<<60
#define rep(i,a,b) for (ll i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
#define endl "\n"
void inc(ll &a,ll b) {a=(a+b)%mod;}
void dec(ll &a,ll b) {a=(a-b+mod)%mod;}
int prod(ll a,ll b) {return ll(a)*ll(b)%mod;}
int lowbit(ll x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
 
const ll maxn=222222;
pll a[maxn];
ll b[maxn],l[maxn],r[maxn],ans[maxn];


signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;cin>>n;
	rep(i,1,n+2)cin>>a[i].fi,a[i].se=i;
	rep(i,1,n+1)cin>>b[i];
	sort(a+1,a+n+2);
	sort(b+1,b+n+1);
	rep(i,1,n+1)l[i]=max(l[i-1],a[i].fi-b[i]);
	for(ll i=n+1;i>1;i--)r[i]=max(r[i+1],a[i].fi-b[i-1]);
	rep(i,1,n+2)ans[a[i].se]=max(l[i-1],r[i+1]);
	rep(i,1,n+2)cout<<ans[i]<<" ";	
	return 0;
}
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6616 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6608 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6616 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6608 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 2 ms 6620 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6624 KB Output is correct
23 Correct 2 ms 6652 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 2 ms 6616 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 2 ms 6492 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6616 KB Output is correct
7 Correct 1 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6608 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 2 ms 6620 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 1 ms 6488 KB Output is correct
21 Correct 2 ms 6488 KB Output is correct
22 Correct 2 ms 6624 KB Output is correct
23 Correct 2 ms 6652 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
29 Correct 2 ms 6616 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 2 ms 6492 KB Output is correct
32 Correct 2 ms 6488 KB Output is correct
33 Correct 70 ms 15696 KB Output is correct
34 Correct 70 ms 15920 KB Output is correct
35 Correct 72 ms 15788 KB Output is correct
36 Correct 68 ms 16244 KB Output is correct
37 Correct 79 ms 16464 KB Output is correct
38 Correct 70 ms 16464 KB Output is correct
39 Correct 69 ms 15468 KB Output is correct
40 Correct 70 ms 15448 KB Output is correct
41 Correct 68 ms 15440 KB Output is correct
42 Correct 69 ms 15440 KB Output is correct
43 Correct 73 ms 15456 KB Output is correct
44 Correct 70 ms 15188 KB Output is correct
45 Correct 67 ms 15188 KB Output is correct
46 Correct 67 ms 15044 KB Output is correct
47 Correct 66 ms 15104 KB Output is correct
48 Correct 66 ms 14932 KB Output is correct
49 Correct 70 ms 15696 KB Output is correct
50 Correct 74 ms 15576 KB Output is correct
51 Correct 70 ms 15696 KB Output is correct
52 Correct 74 ms 15700 KB Output is correct
53 Correct 76 ms 15576 KB Output is correct