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 |
再来一个WA代码。。。。。。。。。。。心好痛。。。没法证明但是错了。。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator