[杂题] Codeforces 830C Round #424 Div1 C. Bamboo Partition

随便搞搞吧

#include
#include
#include
using namespace std;
typedef long long ll;

#define read(x) scanf("%d",&(x))

const int maxn=200005;
const int P=1e9+7;

const int N=505;

int n,a[N];

inline ll check(ll d){
  ll ret=0;
  for (int i=1;i<=n;i++)
    ret+=(a[i]+d-1)/d;
  return ret;
}
ll K;

ll sx[10000005],icnt;

int main(){
  freopen("t.in","r",stdin);
  freopen("t.out","w",stdout);
  read(n); scanf("%I64d",&K);
  for (int i=1;i<=n;i++)
    read(a[i]),K+=a[i];
  ll ans=0;
  for (ll i=1,j;i<=K;i=j+1){
    j=K/(K/i);
    if (check(j)<=K/j)
      ans=max(j,ans);
  }
  printf("%I64d\n",ans);
  return 0;
}

你可能感兴趣的:(杂题)