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>
#define endl '\n'
using namespace std;
const int MAXN = 55005;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, k, a[MAXN];
void read()
{
cin >> n >> k;
for (int i = 1; i <= n; ++ i)
cin >> a[i];
sort(a+1, a+n+1);
int cnt_false = 0;
vector < int > g;
for(int i = n - k + 1; i <= n; ++ i)
{
g.push_back(a[i]);
if(a[i] > cnt_false)cnt_false ++;
}
for (int i = 1; i <= n - k; ++ i)
{
g.push_back(a[i]);
if(a[i] > cnt_false)
{
cnt_false ++;
return;
}
}
//cout << cnt_false << endl;
if(cnt_false == k)
{
for (int i = g.size()-1; i >= 0; -- i)
cout << g[i] << " ";
cout << endl;
}
else cout << -1 << endl;
}
int main()
{
speed();
read();
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... |