Submission #900453

#TimeUsernameProblemLanguageResultExecution timeMemory
900453n3rm1nKarte (COCI18_karte)C++17
36 / 120
5 ms860 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 55005; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, k, a[MAXN]; void read() { cin >> n >> k; for (int i = 1; i <= n; ++ i) cin >> a[i]; sort(a+1, a+n+1); int cnt_false = 0; vector < int > g; for(int i = n - k + 1; i <= n; ++ i) { g.push_back(a[i]); if(a[i] > cnt_false)cnt_false ++; } for (int i = 1; i <= n - k; ++ i) { g.push_back(a[i]); if(a[i] > cnt_false) { cnt_false ++; return; } } //cout << cnt_false << endl; if(cnt_false == k) { for (int i = g.size()-1; i >= 0; -- i) cout << g[i] << " "; cout << endl; } else cout << -1 << endl; } int main() { speed(); read(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...