Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

I don't know why it is WA.

Posted by is2subi at 2007-05-24 06:27:25 on Problem 3104
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator