Language: C++

#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
int main(){
    int n,k;
    cin >> n>>k;
    double a[n];
    int am=0;
    rep(i,n){
        cin >> a[i];
        am=max(am,a[i]);
    }
    if(k==0){
        cout<<am<<endl;
        return 0;
    }
    double l=0,r=INF;
    while((int)r!=(int)l){
        int temp=0;
        double p=(r+l)/2;
        rep(i,n){
            if(a[i]/p==(int)a[i]/p){
                temp+=a[i]/p;
            }else{
                temp+=(int)(a[i]/p)+1;
            }
        }
        if(temp>k){
            l=p;
        }else{
            r=p;
        }
    }
    //cerr<<r<<' '<<l<<endl;
    int ans=0;
    int temp=0;
    double p=r;
    rep(i,n){
        if(a[i]/p==(int)(a[i]/p)){
            temp+=(a[i]/p);
        }else{
            temp+=(int)(a[i]/p)+1;
        }
    }
    if(temp>k){
        if(l==(int)l){
            ans=l;
        }else{
            ans=(int)l+1;
        }
        //cerr<<l<<endl;
    }else{
        if(r==(int)r){
            ans=r;
        }else{
            ans=(int)r+1;
        }
        //cerr<<r<<endl;
        //cerr<<((int)r)<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:15: error: no matching function for call to 'max(int&, double&)'
   37 |         am=max(am,a[i]);
      |            ~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:37:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   37 |         am=max(am,a[i]);
      |            ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:37:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |         am=max(am,a[i]);
      |            ~~~^~~~~~~~~