제출 #13956

#제출 시각아이디문제언어결과실행 시간메모리
13956gs14004버블 정렬 (OJUZ10_bubblesort)C++14
0 / 100
54 ms3628 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...