Submission #239047

# Submission time Handle Problem Language Result Execution time Memory
239047 2020-06-14T08:20:22 Z VEGAnn Vrtić (COCI18_vrtic) C++14
32 / 160
5 ms 384 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define i2 array<int,2>
#define PB push_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 510;
const ll OO = 1e18;
const int md = int(1e9) + 7;
int n, nt[N], a[N], ans[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> nt[i];
        nt[i]--;
    }

    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a, a + n);

    ans[0] = a[0];

    int fi = 0, se = 0, it = 1;

    while (it < n){
        if (it & 1){
            fi++;

            if (fi == n) fi -= n;

            if (fi == se) break;

            ans[fi] = a[it];
        } else {
            se--;

            if (se < 0) se += n;

            if (fi == se) break;

            ans[se] = a[it];
        }

        it++;
    }

    int sum = 0;

    for (int i = 0; i < n; i++)
        sum = max(sum, abs(ans[i] - ans[(i + 1) % n]));

    cout << sum << '\n';

    for (int i = 0; i < n; i++)
        cout << ans[i] << " ";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
# 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
# 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 4 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 -