# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
785791 |
2023-07-17T15:29:01 Z |
Nanu25 |
Karte (COCI18_karte) |
C++17 |
|
159 ms |
6660 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 = 1; i <= n - k; i++)
a[++t] = v[i]; //le pun pe cele mai mici pe primele pozitii caci pot fii adevarate;
for(int i = n; i > n - k; i--)
a[++t] = v[i]; //pun cele mai mari k numere pe ultimele pozitii pentru ca sunt singurele care pot fii false;
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 |
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 |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
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 |
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 |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1492 KB |
Output is correct |
2 |
Correct |
29 ms |
1344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
2768 KB |
Output is correct |
2 |
Correct |
60 ms |
2024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
6660 KB |
Output is correct |
2 |
Correct |
121 ms |
4332 KB |
Output is correct |