Submission #104684

# Submission time Handle Problem Language Result Execution time Memory
104684 2019-04-08T19:48:54 Z IVIosab Karte (COCI18_karte) C++17
120 / 120
129 ms 6860 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define ll long long

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    sort(ar,ar+n);
    vector<int> v;
    for(int i=0;i<n-k;i++){
        v.push_back(ar[i]);
    }
    for(int i=n-1;i>=n-k;i--){
        v.push_back(ar[i]);
    }
    int fss=0,z=0;
    for(int i=n-1;i>=0;i--){
        if(fss<v[i]){
            fss++;
            z++;
        }
    }
    if(z!=k){
        cout<<-1<<endl;
    }
    else{
        for(int i=0;i<n;i++){
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1788 KB Output is correct
2 Correct 19 ms 1532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 3088 KB Output is correct
2 Correct 37 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 6860 KB Output is correct
2 Correct 77 ms 4464 KB Output is correct