This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a).size()
#define pb push_back
#define fi first
#define se second
#define For(i,a,b) for(int i=(a); i<=(b); ++i)
#define roF(i,a,b) for(int i=(a); i>=(b); --i)
using namespace std;
#ifdef DEBUG__
void dmpr(ostream &os){ os << "\n"; }
template<class T, class... Args>
void dmpr(ostream &os, const T &t, const Args &... args){
os << t << " ";
dmpr(os, args...);
}
#define dbg(...) dmpr(cerr, __LINE__, ##__VA_ARGS__)
#else
#define dbg(...) void(0)
#endif
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef long double ld;
const int N=200005;
const int inf=0x3f3f3f3f;
mt19937 rng(random_device {}());
int rand(int a){
return rng()%a;
}
int n, b[N], pref[N], suf[N], res[N];
pi a[N];
void rmain(){
cin >> n;
For(i,1,n+1){
cin >> a[i].fi; a[i].se=i;
}
For(i,1,n) cin >> b[i];
sort(a+1, a+n+2);
sort(b+1, b+n+1);
For(i,1,n) pref[i]=max(pref[i-1], a[i].fi-b[i]);
roF(i,n,1) suf[i]=max(suf[i+1], a[i+1].fi-b[i]);
For(i,1,n+1) res[a[i].se]=max(pref[i-1], suf[i]);
For(i,1,n+1) cout << res[i] << " ";
}
signed main(int argc, char *argv[]){
iostream::sync_with_stdio(0);
int T=1;
while(T--) rmain();
return 0;
}
Compilation message (stderr)
ho_t1.cpp:47:8: warning: first argument of 'int main(long long int, char**)' should be 'int' [-Wmain]
47 | signed main(int argc, char *argv[]){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |