题意:
思路:二分答案A
合法的答案 sigma(s[i][xi])/sigma(xi)>=a i<=m
sigma(s[i][xi]-a*xi)>=0
对于每个i找到xi使s[i][xi]-a*xi最大累加验证答案即可
1 var a,s:array[1..100000]of int64; 2 n,m,i,j:longint; 3 l,r,mid,last:real; 4 5 function isok(a:real):boolean; 6 var i,j:longint; 7 t,tmp:real; 8 begin 9 tmp:=0; 10 for i:=1 to n do 11 begin 12 t:=s[(i-1)*m+1]-a; 13 for j:=2 to m do 14 if s[(i-1)*m+j]-a*j>t then t:=s[(i-1)*m+j]-a*j; 15 tmp:=tmp+t; 16 end; 17 if tmp>=0 then exit(true) 18 else exit(false); 19 end; 20 21 begin 22 assign(input,'gold.in'); reset(input); 23 assign(output,'gold.out'); rewrite(output); 24 readln(n,m); 25 for i:=1 to n*m do read(a[i]); 26 for i:=1 to n do 27 begin 28 s[(i-1)*m+1]:=a[(i-1)*m+1]; 29 for j:=2 to m do s[(i-1)*m+j]:=s[(i-1)*m+j-1]+a[(i-1)*m+j]; 30 end; 31 l:=0; r:=1000000000; last:=0; 32 while r-l>1e-5 do 33 begin 34 mid:=(l+r)/2; 35 if isok(mid) then begin last:=mid; l:=mid; end 36 else r:=mid; 37 end; 38 writeln(last:0:4); 39 close(input); 40 close(output); 41 end.