Submission #900683

#TimeUsernameProblemLanguageResultExecution timeMemory
900683n3rm1nKarte (COCI18_karte)C++17
120 / 120
85 ms9928 KiB
#include<bits/stdc++.h> #define endl '\n' #pragma GCC optimize("Ofast") using namespace std; const int MAXN = 5e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, k, a[MAXN]; void read() { cin >> n >> k; int cnt0 = 0; for (int i = 1; i <= n; ++ i) { cin >> a[i]; if(!a[i])cnt0 ++; } sort(a+1, a+n+1); if(k == 0) { if(cnt0 != n)cout << -1 << endl; else { for (int i = 1; i <= n; ++ i) cout << a[i] << " "; cout << endl; } exit(0); } 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 ++; } } //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...