#include<bits/stdc++.h>usingnamespace std;constdouble eps =1e-6;int n, k;double a[10005];intmain(){#ifdef LOCALfreopen("E:\\Cpp\\1.in","r",stdin);#endifscanf("%d %d",&n,&k);double sum =0, l =0, r =0;for(int i =0; i < n; i++){scanf("%lf",&a[i]);
sum += a[i];
l =max(l, a[i]/ k);}
r = sum / k;while(r - l > eps){double mid =(l + r)/2;int num =0;for(int i =0; i < n; i++){
num += a[i]/ mid;}if(num >= k)
l = mid;else
r = mid;}printf("%.2lf\n",floor(100* r)/100);return0;}
分梨
#include<cstdio>typedeflonglong ll;int n;
ll a, b, c, m1, m2;int dp[2123][2123];int ans =0;intmain(){#ifdef LOCALfreopen("E:\\Cpp\\1.in","r",stdin);#endifscanf("%d%lld%d%lld",&n,&a,&b,&c);for(int i =0; i != n;++i){
ll v1, v2;scanf("%lld%lld",&v1,&v2);if(v1 > m1)
m1 = v1;if(v2 > m2)
m2 = v2;int x = v1, y = v2;while(x !=0){int l =(a *(v1 - x)+ b * v2 - c)/ b, r = v2 +1;if(l <0)
l =0;while(r > l){int mid =(l + r)/2;if(a *(v1 - x)+ b *(v2 - mid)<= c){
y = mid;
r = mid;}else
l = mid +1;}if(y <= v2 +1)//判断范围{++dp[x][y];//差分--dp[x][v2 +1];}
y = v2 +1;--x;}}for(int i =0; i <= m1;++i){int sum =0;for(int j =0; j <= m2;++j){
sum += dp[i][j];//前缀和获得原dp数组if(sum > ans)
ans = sum;}}printf("%d\n", ans);return0;}