Submission #1066007

#TimeUsernameProblemLanguageResultExecution timeMemory
1066007NemanjaSo2005Growing Vegetables is Fun 5 (JOI24_vegetables5)C++17
30 / 100
5014 ms20940 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=3e5+5; int N,niz[2*maxn],R[maxn],B[maxn]; int resi(){ vector<int> A,BB; int ret=1e9; for(int p=1;p<=N+1;p++){ int k=p+N-1; int tmp=0; A.clear(); BB.clear(); for(int i=1;i<=2*N;i++) if(i>=p and i<=k) A.push_back(niz[i]); else BB.push_back(niz[i]); sort(A.begin(),A.end()); sort(BB.begin(),BB.end()); for(int i=1;i<=N;i++){ tmp=max(tmp,abs(R[i]-A[i-1])); tmp=max(tmp,abs(B[i]-BB[i-1])); } ret=min(ret,tmp); } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin>>N; for(int i=1;i<=2*N;i++) cin>>niz[i]; for(int i=1;i<=N;i++) cin>>R[i]; for(int i=1;i<=N;i++) cin>>B[i]; sort(R+1,R+1+N); sort(B+1,B+1+N); int res=resi(); for(int i=1;i<=N;i++) swap(R[i],B[i]); res=min(res,resi()); cout<<res<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...