This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <queue>
#include <fstream>
#include <algorithm>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
const ll oo = 1e18;
int n, a[N], best = 1e9;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
}
for (int i = 0; i < n; ++i)
cin >> a[i];
sort(a, a + n);
vector <int> res(n);
res[0] = a[0];
for (int i = 1; i < n; ++i)
if (i & 1) res[(i + 1) / 2] = a[i];
else res[n - (i / 2)] = a[i];
best = abs(res[0] - res[n - 1]);
for (int i = 1; i < n; ++i)
best = max(best, abs(res[i] - res[i - 1]));
cout << best << "\n";
for (int i = 0; i < n; ++i)
cout << res[i] << ' ';
}
# | 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... |
# | 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... |