This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//de y tung cac mang 1
#include<bits/stdc++.h>
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define pb push_back
#define ii pair<int,int>
#define fi first
#define se second
using namespace std;
const int M=2e5+10;
int n,b[M],ret[M],f[M],g[M];
ii a[M];
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen("1.inp","r"))
{
freopen("1.inp","r",stdin);
freopen("1.out","w",stdout);
}
cin >> n;
fori(i,1,n+1)
{
cin >> a[i].fi;
a[i].se=i;
}
fori(i,1,n) cin >> b[i];
sort(a+1,a+n+2);
sort(b+1,b+n+1);
//fori(i,1,n+1) cout << a[i] << " ";
fori(i,1,n) f[i]=max(f[i-1],max(0ll,a[i].fi-b[i]));
for(int i=n+1;i!=1;i--) g[i]=max(g[i+1],max(0ll,a[i].fi-b[i-1]));
fori(i,1,n+1) ret[a[i].se]=max(f[i-1],g[i+1]);
fori(i,1,n+1) cout << ret[i] << " ";
}
Compilation message (stderr)
ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | freopen("1.inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | freopen("1.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |