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

再来一个WA代码。。。。。。。。。。。心好痛。。。没法证明但是错了。。。。

Posted by 2745972075 at 2014-07-17 23:58:29 on Problem 2456
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int arr[100011];

int main(){
    int n , m;
    while(scanf("%d%d",&n , &m)>0){
        for(int i=1 ;i<=n ; ++i)
            scanf("%d",arr + i);
        sort(arr+1 , arr+n+1);
        int max = 0;
        int left = 2 , right = n;
        while(left <= right){
            int mid = (left + right)>>1;
            int c = m-1;
            int d = arr[mid] - arr[1];
            int a=arr[1];
            for(int i=2; i<=n ; ++i){
                if(arr[i] - a >= d) {
                    a = arr[i];
                    --c;
                }
            }
            if(c<=0 && max<=d) {max = d;}
            if(c<=0) left = mid +1;
            else right = mid - 1 ;
        }
        cout<<max <<endl;
    }
}

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