Submission #566969

#TimeUsernameProblemLanguageResultExecution timeMemory
566969DodoJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
111 ms11644 KiB
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define pb push_back using namespace std; const ll mx=1007, INF=1e18L+5; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin>>n; ll b[n]; vector<pair<ll,ll>>v(n+1); for(int i=0;i<=n;i++) { ll x; cin>>x; v[i]={x,i}; } for(int i=0;i<n;i++)cin>>b[i]; sort(v.begin(),v.end()); sort(b,b+n); ll p1[n],p2[n]; ll mx=0; for(int i=0;i<n;i++) { mx=max(mx,v[i].first-b[i]); p1[i]=mx; } mx=0; for(int i=n;i>=1;i--) { mx=max(mx,v[i].first-b[i-1]); p2[i-1]=mx; } ll f[n+1]; for(int i=0;i<=n;i++) { ll x,y,ans=0; if(i-1>=0)ans=max(ans,p1[i-1]); if(i!=n)ans=max(ans,p2[i]); f[v[i].second]=ans; } for(int i=0;i<=n;i++)cout<<f[i]<<' '; return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:45:8: warning: unused variable 'x' [-Wunused-variable]
   45 |     ll x,y,ans=0;
      |        ^
ho_t1.cpp:45:10: warning: unused variable 'y' [-Wunused-variable]
   45 |     ll x,y,ans=0;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...