This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// cout.tie(NULL);
int n, k;
cin >> n >> k;
vector <int> a(n);
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a.begin(), a.end());
vector <int> res;
for(int i = n - k; i < n; i++)
{
res.push_back(a[i]);
}
for(int i = 0; i < n - k; i++)
{
res.push_back(a[i]);
}
int cnt = 0;
for(int i = 0; i < k; i++)
{
if(cnt >= res[i])
{
cout << -1;
return 0;
}
cnt++;
}
for(int i = k; i < n; i++)
{
if(cnt < res[i])
{
cout << -1;
return 0;
}
}
reverse(res.begin(), res.end());
for(int i = 0; i < n; i++)
{
cout << res[i] << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |