Submission #471471

#TimeUsernameProblemLanguageResultExecution timeMemory
471471FatihSolakJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
115 ms12340 KiB
#include <bits/stdc++.h> #define N 200005 #define int long long using namespace std; int brr[N]; pair<int,int> arr[N]; int res[N]; void solve(){ int n; cin >> n; for(int i=1;i<=n+1;i++){ cin >> arr[i].first; arr[i].second = i; } for(int i=1;i<=n;i++){ cin >> brr[i]; } sort(arr+1,arr+n+2); sort(brr+1,brr+n+1); int ans = 0; for(int i=1;i<=n;i++)ans = max(ans,arr[i].first-brr[i]); res[arr[n+1].second] = ans; for(int i=n;i>=1;i--){ ans = max(ans,arr[i+1].first-brr[i]); res[arr[i].second] = ans; } for(int i=1;i<=n+1;i++)cout << res[i] << " "; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...