Submission #237539

# Submission time Handle Problem Language Result Execution time Memory
237539 2020-06-07T08:17:39 Z NONAME Karte (COCI18_karte) C++17
84 / 120
1000 ms 2296 KB
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define el '\n'
using namespace std;

typedef long long ll;
const int N = 5e5 + 10;

int n, k, a[N];

bool gd(int x) {
    int cur = 0;

    for (int i = 0; i < n; i++)
        if (a[(i + x) % n] > cur)
            cur++;

    return cur == k;
}

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

    cin >> n >> k;

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

    sort(a, a + n);

    for (int i = 0; i < n; ++i)
        if (gd(i)) {
            for (int j = n - 1; j >= 0; --j)
                cout << a[(i + j) % n] << ' ';

            return 0;
        }

    cout << -1;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 27 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 27 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 1152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 2296 KB Time limit exceeded
2 Halted 0 ms 0 KB -