Submission #224012

#TimeUsernameProblemLanguageResultExecution timeMemory
224012lycJust Long Neckties (JOI20_ho_t1)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) (int)(x).size() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for (int i=(a);i>=(b);--i) const int MX_N = 2e5+5; int N; pair<int,int> A[MX_N]; int B[MX_N]; int P[MX_N], Q[MX_N], ans[MX_N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; FOR(i,1,N+1){ cin >> A[i].first; A[i].second = i; } FOR(i,1,N){ cin >> B[i]; } sort(A+1,A+1+N+1); sort(B+1,B+1+N); FOR(i,1,N){ P[i] = max(P[i-1], max(A[i].first-B[i],0)); } RFOR(i,N,1){ Q[i] = max(P[i+1], max(A[i+1].first-B[i],0)); } FOR(i,1,N+1){ ans[A[i].second] = max(P[i-1],Q[i]); } FOR(i,1,N+1){ cout << ans[i] << (i==N+1?'\n':' '); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...