Loading

代码-CF830C Bamboo Partition

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);i>=0;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;

//Data
const int N=100;
int n,a[N];
ll k,sm,ns=0;

//Main
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>n>>k,sm=k+n;
    R(i,n) cin>>a[i],--a[i],sm+=a[i];
    // cout<<"sm="<<sm<<'\n';
    for(ll l=1,r,tot;l<=sm;l=r+1){
        r=sm/(sm/l),tot=0;
        R(i,n)if(a[i]>=l) r=min(r,1ll*a[i]/(a[i]/l));
        R(i,n) tot+=a[i]/l;
        if(tot<=sm/l-n) ns=max(ns,r);
    }
    cout<<ns<<'\n';
    return 0;
}
posted @ 2020-12-25 18:18  George1123  阅读(17)  评论(0编辑  收藏  举报