Submission #239566

#TimeUsernameProblemLanguageResultExecution timeMemory
239566MrRobot_28Karte (COCI18_karte)C++17
120 / 120
293 ms13920 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // cout.tie(NULL); int n, k; cin >> n >> k; vector <int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); vector <int> res; for(int i = n - k; i < n; i++) { res.push_back(a[i]); } for(int i = 0; i < n - k; i++) { res.push_back(a[i]); } int cnt = 0; for(int i = 0; i < k; i++) { if(cnt >= res[i]) { cout << -1; return 0; } cnt++; } for(int i = k; i < n; i++) { if(cnt < res[i]) { cout << -1; return 0; } } reverse(res.begin(), res.end()); for(int i = 0; i < n; i++) { cout << res[i] << " "; } 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...