Submission #706896

#TimeUsernameProblemLanguageResultExecution timeMemory
706896Koful123Karte (COCI18_karte)C++17
120 / 120
102 ms13884 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() void solve(){ int n,k; cin >> n >> k; vector<int> v(n); for(int i = 0; i < n; i++){ cin >> v[i]; } sort(rall(v)); for(int i = 0; i < k; i++){ if(v[i] < k - i){ cout << -1 << endl; return; } } vector<int> ans; for(int i = k - 1; i >= 0; i--){ ans.pb(v[i]); } for(int i = k; i < n; i++){ if(v[i] > k){ cout << -1 << endl; return; } ans.pb(v[i]); } reverse(all(ans)); for(int x : ans){ cout << x << ' '; } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--) solve(); 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...