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 <cstdio>
#include <queue>
#include <set>
using namespace std;
typedef pair<int,int> pi;
int n,k,a[100005],ret[100005];
bool vis[100005];
priority_queue<pi> pq;
int main(){
scanf("%d %d",&n,&k);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
pq.push(pi(a[i],i));
}
int pt = n-1;
while (k--) {
pi t = pq.top();
pq.pop();
vis[t.second] = 1;
ret[pt--] = t.first;
}
for (int i=n-1; i>=0; i--) {
if(!vis[i]){
ret[pt--] = a[i];
}
}
for (int i=0; i<n; i++) {
printf("%d ",ret[i]);
}
}
# | 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... |