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

Re:送点test data给WA的朋友们……

Posted by smallbox at 2008-11-10 16:26:18 on Problem 3104
In Reply To:送点test data给WA的朋友们…… Posted by:MIRKING at 2008-07-31 13:39:06
数据都对了还是过不了,DBUG的能力到底要何时才能提升啊
#include "iostream"
int N,K;
int a[100000];
int max;
bool OK(int t)
{
    int sum=0;
    for(int i=0;i<N;i++)
    {
        int X1=a[i]-t;
        int X2=K-1;
        int d=X1/X2;
        if(X1%X2!=0)d++;
        sum=sum+d;        
        if(sum>t)return false;
    }     
    return true;
}
int Bserch()
{
    int low=0,high=max;
    int mid;
    while(1)
    {
       mid=(low+high)/2;
       if(mid==low)return high;        
       if(OK(mid))
       {
           high=mid;           
       }
       else
       {
           low=mid;
       }
    }   
}
main()
{
    while(scanf("%d",&N)!=EOF)
    {
    max=0;
    for(int i=0;i<N;i++)
    {
      scanf("%d",&a[i]);
      max>?=a[i];
    }
    scanf("%d",&K);
    printf("%d\n",Bserch());  
    }
}


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