Submission #1036614

#TimeUsernameProblemLanguageResultExecution timeMemory
1036614UnforgettableplGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++17
30 / 100
5018 ms30292 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e13; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> arr(2*n+1); for(int i=1;i<=2*n;i++)cin>>arr[i]; vector<int> B(n); for(int&i:B)cin>>i; sort(B.begin(),B.end()); vector<int> C(n); for(int&i:C)cin>>i; sort(C.begin(),C.end()); int ans = INT64_MAX; for(int i=1;i<=n+1;i++){ vector<int> pota,potb; for(int j=i;j<i+n;j++)pota.emplace_back(arr[j]); for(int j=1;j<i;j++)potb.emplace_back(arr[j]); for(int j=i+n;j<=2*n;j++)potb.emplace_back(arr[j]); sort(pota.begin(),pota.end()); sort(potb.begin(),potb.end()); { int myans = 0; for(int j=0;j<n;j++)myans=max(myans,abs(pota[j]-B[j])); for(int j=0;j<n;j++)myans=max(myans,abs(potb[j]-C[j])); ans=min(ans,myans); } swap(pota,potb); { int myans = 0; for(int j=0;j<n;j++)myans=max(myans,abs(pota[j]-B[j])); for(int j=0;j<n;j++)myans=max(myans,abs(potb[j]-C[j])); ans=min(ans,myans); } } cout << ans << '\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...