Submission #580147

# Submission time Handle Problem Language Result Execution time Memory
580147 2022-06-20T16:07:21 Z Yazan_SA Karte (COCI18_karte) C++14
120 / 120
105 ms 5208 KB
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define map unordered_map
#define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
int main()
{
    start
    //freopen("codeblocksinput.txt", "r", stdin);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n, k, act=0;
        cin>>n>>k;
        vector<int>v(n);
        for(int i=0; i<n; cin>>v[i++]);
        sort(v.begin(), v.end(), greater<int>());
        sort(v.begin(), v.begin()+k);
        for(int i=0; i<n; i++)
            if(v[i]>act)
                act++;
        if(act==k)
            for(int i=n-1; i>=0; i--)
                cout<<v[i]<<' ';
        else
            cout<<-1;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1216 KB Output is correct
2 Correct 16 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2116 KB Output is correct
2 Correct 29 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 4832 KB Output is correct
2 Correct 74 ms 5208 KB Output is correct