# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
785784 |
2023-07-17T15:20:44 Z |
Nanu25 |
Karte (COCI18_karte) |
C++17 |
|
149 ms |
6744 KB |
#include <iostream>
#include <algorithm>
using namespace std;
const int DIM = 5 * 1e5;
int n, k;
int v[DIM + 5], a[DIM + 5];
int main() {
cin >> n >> k;
for(int i = 1; i <= n; i++)
cin >> v[i];
sort(v + 1, v + n + 1);
int t = 0;
for(int i = n - k; i >= 1; i--)
a[++t] = v[i];
for(int i = n; i > n - k; i--)
a[++t] = v[i]; //pun cele mai mari k numere pe primele pozitii
int fals = 0;
for(int i = n; i >= 1; i--)
if(a[i] > fals)
fals++;
if(fals != k)
cout << -1;
else for(int i = 1; i <= n; i++)
cout << a[i] << " ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1580 KB |
Output is correct |
2 |
Correct |
25 ms |
1224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
2796 KB |
Output is correct |
2 |
Correct |
50 ms |
1976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
6744 KB |
Output is correct |
2 |
Correct |
127 ms |
4488 KB |
Output is correct |