| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
I don't know why it is WA.#include <stdio.h>
int main(void) {
int N, A[100010], K;
int i, min = 1, max = 0, mid, sum;
scanf("%d", &N);
for(i = 1; i <= N; i++) {
scanf("%d", &A[i]);
if(A[i] > max) max = A[i];
}
scanf("%d", &K);
if(K <= 1) {printf("%d\n", max); return 0;}
while(min < max) {
mid = (min + max) / 2;
sum = 0;
for(i = 1; i <= N; i++) {
if(A[i] > mid) {
sum += (A[i] - mid) / (K - 1);
if((A[i] - mid) % (K - 1)) sum++;
}
}
if(sum <= mid) {
max = mid;
} else {
min = mid + 1;
}
}
printf("%d\n", max);
return 0;
}
Where is the problem?
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator