Submission #14430

#TimeUsernameProblemLanguageResultExecution timeMemory
14430ainta버블 정렬 (OJUZ10_bubblesort)C++98
100 / 100
68 ms2660 KiB
#include<stdio.h> #include<algorithm> using namespace std; int n, K, H[101000], P[101000], top; struct A{ int a, num; bool operator<(const A &p)const{ return a < p.a; } }w[101000]; int main(){ int i; scanf("%d%d", &n, &K); for (i = 1; i <= n; i++){ scanf("%d", &w[i].a); w[i].num = i; } sort(w + 1, w + n + 1); for (i = 1; i <= n; i++){ P[w[i].num] = i; } for (i = 1; i <= n + K; i++){ if (i <= n){ H[top++] = -P[i]; push_heap(H, H + top); } if (i <= K)continue; printf("%d ", w[-H[0]].a); pop_heap(H, H + top); top--; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...