이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |