# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
706896 |
2023-03-08T05:35:58 Z |
Koful123 |
Karte (COCI18_karte) |
C++17 |
|
102 ms |
13884 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3140 KB |
Output is correct |
2 |
Correct |
14 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
5708 KB |
Output is correct |
2 |
Correct |
27 ms |
3276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
13884 KB |
Output is correct |
2 |
Correct |
64 ms |
7600 KB |
Output is correct |