Submission #237524

# Submission time Handle Problem Language Result Execution time Memory
237524 2020-06-07T07:23:19 Z VEGAnn Karte (COCI18_karte) C++14
84 / 120
1000 ms 1912 KB
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 200100;
int n, k, a[N], b[N];

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

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

    cin >> n >> k;

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

    sort(a, a + n);

    for (int kl = 0; kl <= n; kl++){
        for (int i = n - kl, j = 0; i < n; i++, j++)
            b[j] = a[i];

        for (int i = 0, j = kl; i < n - kl; i++, j++)
            b[j] = a[i];

        int cnt = 0;

        for (int i = 0; i < n; i++)
            if (b[i] > cnt)
                cnt++;

        if (cnt == k){
            for (int i = n - 1; i >= 0; i--)
                cout << b[i] << " ";
            return 0;
        }
    }

    cout << -1;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 404 KB Output is correct
2 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 936 ms 1684 KB Output is correct
2 Execution timed out 1088 ms 1664 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 1912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 197 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -