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<stdio.h>
#include<algorithm>
using namespace std;
int a[100010],visit[100010];
struct data{
int num,g;
}b[100010];
int cmp(const data&p,const data&q){return p.g<q.g;}
int main() {
int n,k,i,j;
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++){scanf("%d",&a[i]);b[i].g=a[i];b[i].num=i;}
sort(b+1,b+n+1,cmp);
for(i=n;i>n-k;i--)visit[b[i].num]=1;
for(i=1;i<=n;i++)if(visit[i]==0)printf("%d ",a[i]);
for(i=n-k+1;i<=n;i++)printf("%d ",b[i].g);
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... |