| ||||||||||
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 |
坑死爹了,改了一万上啊,各种改,后来竟然直接用C++交就过了有木有啊!G++无限WA啊!求解释,求原理啊! #include <iostream> #include <cstdio> #define ll long long using namespace std; const int N=1e4+5; const double eps=1e-9; const int inf=1e9; int len[N]; int max(int a,int b){ return a>b?a:b; } int main() { //freopen("in.in","r",stdin); int n,k,ans; double tmp; while(~scanf("%d%d",&n,&k)) { int l=0,r,mid; for(int i=0;i<n;i++) { cin>>tmp; //scanf("%lf",&tmp); len[i]=(int)(tmp*100+eps); r=max(r,len[i]); } ans=0; while(l<=r) { mid=(l+r)/2; int sum=0; if(mid==0) sum=inf; else for(int i=0;i<n;sum+=len[i]/mid,i++); if(sum>=k) { ans=max(ans,mid); l=mid+1; } else r=mid-1; } printf("%.2lf\n",ans*0.01); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator