Submission #448055

#TimeUsernameProblemLanguageResultExecution timeMemory
448055sidpark1Karte (COCI18_karte)C++17
96 / 120
28 ms2504 KiB
#include <bits/stdc++.h> using namespace std; int64_t n, k, a[100000+1], temp = 0; vector<int64_t> ans; bool possible = true; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int64_t i=0; i<n; i++) { cin >> a[i]; } sort(a,a+n); for(int64_t i=n-k; i<n; i++) { ans.push_back(a[i]); } for(int64_t i=0; i<n-k; i++) { ans.push_back(a[i]); } for(int64_t i=0; i<n; i++) { if(i < k) { if(ans[i] <= temp) { possible = false; break; } temp++; } else if(ans[i] > k) { possible = false; break; } } if(!possible) cout << "-1\n"; else { reverse(ans.begin(), ans.end()); for(auto i : ans) { cout << i << " "; } cout << '\n'; } }
#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...