Language: C++

#include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<ll>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define sz(x) (ll)x.size() 
#define ara cout<<"ara-ara\n"; 
const ld pi=3.141592653589793238;

inline ll ceil(ll a,ll b)
{
   return (a+b-1)/b;
}

const ll N=2e5+5;
ll arr[N],n,k;

bool can(ll x)
{
  ll res=0;
  f(i,1,n+1) res+=(ceil(arr[i],x)-1);
  return res<=k;
}

bool can2(ld x)
{
  ll res=0,temp2;
  ld temp;
  f(i,1,n+1)
  {
    temp=((ld)arr[i]/x);
    temp2=(ll)temp;
    if((ld)temp2==temp) res+=(temp2-1);
    else res+=temp2;
  }
  return res<=k;
}

void func()
{
  cin>>n>>k;
  f(i,1,n+1) cin>>arr[i];

  ll lef=1,rig=1e9+2,mid,ans=-1;
  while(lef<=rig)
  {
    mid=(lef+rig)>>1;
    if(can(mid)) ans=mid,rig=mid-1;
    else lef=mid+1;
  }

  ld x=ans;
  x-=0.51;

  if(can2(x)) ans--;

  cout<<ans<<"\n";

}   
     
     
     
int main() 
{
    fast
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif // ONLINE_JUDGE
     
    ll ntc=1;
    //cin>>ntc;
     #include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<ll>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define sz(x) (ll)x.size() 
#define ara cout<<"ara-ara\n"; 
const ld pi=3.141592653589793238;

inline ll ceil(ll a,ll b)
{
   return (a+b-1)/b;
}

const ll N=2e5+5;
ll arr[N],n,k;

bool can(ll x)
{
  ll res=0;
  f(i,1,n+1) res+=(ceil(arr[i],x)-1);
  return res<=k;
}

bool can2(ld x)
{
  ll res=0,temp2;
  ld temp;
  f(i,1,n+1)
  {
    temp=((ld)arr[i]/x);
    temp2=(ll)temp;
    if((ld)temp2==temp) res+=(temp2-1);
    else res+=temp2;
  }
  return res<=k;
}

void func()
{
  cin>>n>>k;
  f(i,1,n+1) cin>>arr[i];

  ll lef=1,rig=1e9+2,mid,ans=-1;
  while(lef<=rig)
  {
    mid=(lef+rig)>>1;
    if(can(mid)) ans=mid,rig=mid-1;
    else lef=mid+1;
  }

  ld x=ans;
  x-=0.51;

  if(can2(x)) ans--;

  cout<<ans<<"\n";

}   
     
     
     
int main() 
{
    fast
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif // ONLINE_JUDGE
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
       //cout<<"Case #"<<i<<": ";
       //cout<<"\n";
       func();
    }
     
    return 0;
}

    f(i,1,ntc+1)
    {
       //cout<<"Case #"<<i<<": ";
       //cout<<"\n";
       func();
    }
     
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:121:1: error: a function-definition is not allowed here before '{' token
  121 | {
      | ^
a.cc:129:1: error: a function-definition is not allowed here before '{' token
  129 | {
      | ^
a.cc:136:1: error: a function-definition is not allowed here before '{' token
  136 | {
      | ^
a.cc:150:1: error: a function-definition is not allowed here before '{' token
  150 | {
      | ^
a.cc:173:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  173 | int main()
      |         ^~
a.cc:173:9: note: remove parentheses to default-initialize a variable
  173 | int main()
      |         ^~
      |         --
a.cc:173:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:174:1: error: a function-definition is not allowed here before '{' token
  174 | {
      | ^