Submission #448058

#TimeUsernameProblemLanguageResultExecution timeMemory
448058sidpark1Karte (COCI18_karte)C++17
120 / 120
137 ms11452 KiB
#include <bits/stdc++.h> using namespace std; int64_t n, k, temp = 0; vector<int64_t> ans; bool possible = true; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; int64_t a[n]; 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...