Submission #1163515

#TimeUsernameProblemLanguageResultExecution timeMemory
1163515dnnndaGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++20
0 / 100
1 ms324 KiB
#include<bits/stdc++.h> using namespace std; #define S second #define F first #define ll long long //#define int long long //#pragma GCC optimize("Ofast, unroll-loop") //#pragma GCC target("avx,avx2") #pragma GCC optimize("O3") #define init(arr,val) memset(arr,val,sizeof arr) const int inf=0x3f3f3f3f; const ll inff=0x3f3f3f3f3f3f3f3f; const int X=1000000007; //const int X=998244353; int a[6005], b[3005], c[3005]; int main(){ ios::sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n; for(int i=1 ; i<=n*2 ; i++) cin >> a[i]; for(int i=1 ; i<=n ; i++) cin >> b[i]; for(int i=1 ; i<=n ; i++) cin >> c[i]; sort(b+1,b+n+1), sort(c+1,c+n+1); int ans=inf; for(int i=1 ; i<=n+1 ; i++){ vector<int> v[2]; for(int j=1 ; j<i ; j++) v[0].push_back(a[j]); for(int j=i ; j<=i+n ; j++) v[1].push_back(a[j]); for(int j=i+n+1 ; j<=n*2 ; j++) v[0].push_back(a[j]); sort(v[0].begin(),v[0].end()), sort(v[1].begin(),v[1].end()); int temp=0; for(int j=1 ; j<=n ; j++) temp=max(temp,abs(v[0][j-1]-b[j])); for(int j=1 ; j<=n ; j++) temp=max(temp,abs(v[1][j-1]-a[j])); ans=min(ans,temp); temp=0; for(int j=1 ; j<=n ; j++) temp=max(temp,abs(v[0][j-1]-a[j])); for(int j=1 ; j<=n ; j++) temp=max(temp,abs(v[1][j-1]-b[j])); ans=min(ans,temp); } cout << ans << '\n'; return 0; }
#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...