比赛 |
20121023 |
评测结果 |
AAAAAAAAAA |
题目名称 |
奶牛晒衣服 |
最终得分 |
100 |
用户昵称 |
青阳 |
运行时间 |
0.489 s |
代码语言 |
C |
内存使用 |
2.20 MiB |
提交时间 |
2012-10-23 20:38:00 |
显示代码纯文本
#include <stdio.h>
#include <stdlib.h>
int heap[500000];
int end;
#define left(i) (2 * (i) + 1)
#define right(i) (2 * (i) + 2)
#define parent(i) ((i - 1) / 2)
int com(const void *a, const void *b) { return *(int *)b - *(int *)a; }
void heapify(void)
{
int i = 0, next;
int t = heap[0];
while(left(i) < end){
next = left(i);
if(right(i) < end && heap[right(i)] > heap[left(i)]){
next = right(i);
}
if(t >= heap[next]){
break;
}
heap[i] = heap[next];
i = next;
}
heap[i] = t;
}
int main(void)
{
int i;
int n, a, b;
int t;
freopen("dry.in", "r", stdin);
freopen("dry.out", "w", stdout);
scanf("%d%d%d", &n, &a, &b);
end = n;
for(i = 0; i < n; i++){
scanf("%d", &heap[i]);
}
qsort(heap, n, sizeof(int), com);
for(t = 0; heap[0] > a * t; t++){
heap[0] -= b;
heapify();
}
printf("%d\n", t);
return 0;
}