Submission #239048

# Submission time Handle Problem Language Result Execution time Memory
239048 2020-06-14T08:23:21 Z NONAME Vrtić (COCI18_vrtic) C++17
0 / 160
5 ms 384 KB
#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;
vector <int> res;

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);

    best = a[n - 1] - a[0];
    for (int i = 0; i < n; ++i)
        res.push_back(a[i]);

    for (int i = n - 1; i > 0; --i) {
        vector <int> cur;
        cur.clear();
        int cur_res;

        for (int j = 0; j < n; ++j)
            cur.push_back(a[j]);

        reverse(cur.begin() + i, cur.end());

        cur_res = abs(cur[0] - cur.back());
        for (int j = 0; j < n - 1; ++j)
            cur_res = max(cur_res, abs(cur[j] - cur[j + 1]));

        if (cur_res < best) {
            best = cur_res;
            res = cur;
        }
    }

    cout << best << "\n";
    for (int i = 0; i < n; ++i)
        cout << res[i] << ' ';
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB jury has better answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB jury has better answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB the dissatisfaction value doesn't match with your answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB jury has better answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -