Submission #47106

#TimeUsernameProblemLanguageResultExecution timeMemory
47106BruteforcemanKarte (COCI18_karte)C++11
120 / 120
150 ms9368 KiB
#include "bits/stdc++.h" using namespace std; int a[500010]; int b[500010]; int main(int argc, char const *argv[]) { ios_base :: sync_with_stdio (false); cin.tie (0); int n, k; cin >> n >> k; for(int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); k = n - k; for(int i = 0; i < n; i++) { b[i] = a[(i + k) % n]; } int bad = 0; int good = 0; for(int i = 0; i < n; i++) { if(bad >= b[i]) { ++good; } else { ++bad; } } reverse(b, b + n); if(good == k) { for(int i = 0; i < n; i++) { cout << b[i] << " "; } cout << endl; } else { cout << -1 << endl; } 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...