# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
83137 |
2018-11-05T14:13:08 Z |
luciocf |
Karte (COCI18_karte) |
C++14 |
|
261 ms |
12436 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5+10;
int num[maxn];
int main(void)
{
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> num[i];
sort(num+1, num+n+1);
bool ok = 1;
for (int i = 1; i <= n-k; i++)
if (num[i] > k) ok = 0;
if (!ok)
{
cout << "-1\n";
return 0;
}
int qtd = 0;
for (int i = n-k+1; i <= n; i++)
{
if (qtd >= num[i]) ok = 0;
qtd++;
}
if (!ok)
{
cout << "-1\n";
return 0;
}
for (int i = 1; i < n-k; i++)
cout << num[i] << " ";
if (k != n) cout << num[n-k];
for (int i = n; i >= n-k+1; i--)
cout << " " << num[i];
cout << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
516 KB |
Output is correct |
2 |
Correct |
2 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
632 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
664 KB |
Output is correct |
2 |
Correct |
2 ms |
688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
696 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
756 KB |
Output is correct |
2 |
Correct |
3 ms |
872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
2292 KB |
Output is correct |
2 |
Correct |
52 ms |
2408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
4932 KB |
Output is correct |
2 |
Correct |
88 ms |
5188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
261 ms |
11756 KB |
Output is correct |
2 |
Correct |
216 ms |
12436 KB |
Output is correct |