Submission #1116588

#TimeUsernameProblemLanguageResultExecution timeMemory
1116588vjudge1Just Long Neckties (JOI20_ho_t1)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; deque<int> a,b,aux; for(int i=0;i<n+1;i++){ int x; cin>>x; aux.push_back(x); } for(int i=0;i<n;i++){ int x; cin>>x; a.push_back(x); } stable_sort(a.begin(),a.end()); int ans=0; for(int i=0;i<n;i++){ swap(aux[i],aux[n]); for(int j=0;j<n;j++){ b.push_back(aux[j]); } stable_sort(b.begin(),b.end()); for(int j=0;j<n;j++){ ans=max(ans,abs(b[j]-a[j])); } swap(aux[i],aux[n]); b.clear(); cout<<ans<<' '; ans=0; } aux.pop_back(); stable_sort(aux.begin(),aux.end()); ans=0; for(int i=0;i<n;i++){ ans=max(ans,abs(b[i]-a[i])); } cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...