Submission #239058

#TimeUsernameProblemLanguageResultExecution timeMemory
239058NONAMEVrtić (COCI18_vrtic)C++14
32 / 160
5 ms384 KiB
#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 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...
#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...