제출 #1164296

#제출 시각아이디문제언어결과실행 시간메모리
1164296KhoaDuyGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++17
0 / 100
2753 ms9828 KiB
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define int long long bool solve(int n,int a[],int b[],int c[],int x){ int MaxL=0,MinR=n; for(int i=0;i<n;i++){ int l,r; int low=i,high=n-1; low--,high++; while(high-low>1){ int mid=((high-low)>>1)+low; if(a[mid]-b[i]>=-x){ high=mid; } else{ low=mid; } } l=high; low=i,high=n-1; low--,high++; while(high-low>1){ int mid=((high-low)>>1)+low; if(a[mid]-b[i]<=x){ low=mid; } else{ high=mid; } } r=low; l-=i,r-=i; if(r==n-1-i&&abs(a[2*n-i-1]-b[i])<=x){ r=n; } MaxL=max(MaxL,l),MinR=min(MinR,r); } for(int i=0;i<n;i++){ int l,r; int low=2*n-1-i,high=2*n-1; low--,high++; while(high-low>1){ int mid=((high-low)>>1)+low; if(a[mid]-c[i]<=x){ high=mid; } else{ low=mid; } } l=high; low=2*n-1-i,high=2*n-1; low--,high++; while(high-low>1){ int mid=((high-low)>>1)+low; if(a[mid]-c[i]<=-x){ high=mid; } else{ low=mid; } } r=low; l-=(2*n-1-i),r-=(2*n-1-i); if(r==2*n-1-(2*n-1-i)&&abs(c[i]-a[i])<=x){ r=n; } MaxL=max(MaxL,l),MinR=min(MinR,r); } if(MaxL<=MinR){ return true; } return false; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[2*n],b[n],c[n]; for(int i=0;i<2*n;i++){ cin >> a[i]; } for(int i=0;i<n;i++){ cin >> b[i]; } for(int i=0;i<n;i++){ cin >> c[i]; } sort(b,b+n); sort(c,c+n); int low=0,high=1e9; low--,high++; while(high-low>1){ int mid=((high-low)>>1)+low; if(solve(n,a,b,c,mid)||solve(n,a,c,b,mid)){ high=mid; } else{ low=mid; } } cout << high; }
#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...