Submission #1122305

#TimeUsernameProblemLanguageResultExecution timeMemory
1122305Math4Life2020Growing Vegetables is Fun 5 (JOI24_vegetables5)C++17
30 / 100
5030 ms30304 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll,ll>; const ll INF = 2e18; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; ll ans = INF; ll a[2*N]; vector<ll> b,c; for (ll i=0;i<(2*N);i++) { cin >> a[i]; } for (ll i=0;i<N;i++) { ll x; cin >> x; b.push_back(x); } for (ll i=0;i<N;i++) { ll x; cin >> x; c.push_back(x); } sort(b.begin(),b.end()); sort(c.begin(),c.end()); for (ll i=0;i<N;i++) { ll fval = -INF; ll fval2 = -INF; vector<ll> b1; for (ll j=i;j<(i+N);j++) { b1.push_back(a[j]); } sort(b1.begin(),b1.end()); for (ll j=0;j<N;j++) { fval = max(fval,abs(b1[j]-b[j])); fval2 = max(fval2,abs(b1[j]-c[j])); } vector<ll> c1; for (ll j=0;j<i;j++) { c1.push_back(a[j]); } for (ll j=(i+N);j<(2*N);j++) { c1.push_back(a[j]); } sort(c1.begin(),c1.end()); for (ll j=0;j<N;j++) { fval = max(fval,abs(c1[j]-c[j])); fval2 = max(fval2,abs(c1[j]-b[j])); } ans = min(ans,fval); ans = min(ans,fval2); } 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...