이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |