Language: C++

/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;
 
inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
 
inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}
 
template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }
 
#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong
 
#define eps 1e-6
const int maxn = 2e5 + 30;
long long n, k;
double a[maxn];
long long check(double mid) {
	long long tmp = 0;
	for (int i = 1; i <= n; i++) {
		double po = a[i] / mid;
		tmp += (long long)ceil(po) - 1;
	}
	return (tmp <= k);
}
int main() {
	n = ri(), k = ri();
	int maxx = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		maxx = max(maxx, a[i]);
	}
	if (k == 0) {
		cout << maxx;
		return 0;
	}
	double l = 0, r = 1e9 + 20;
	for (int i = 1; i <= 200; i++) {
		double mid = (l + r) / 2.0;
		if (check(mid)) r = mid;
		else l = mid + eps;
	}
	printf("%.0lf", l);
	return 0;
}


Compiler output:
a.cc: In function 'int readint()':
a.cc:14:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |     register int x = 0, flag = 1;
      |                  ^
a.cc:14:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |     register int x = 0, flag = 1;
      |                         ^~~~
a.cc:15:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |     register char ch;
      |                   ^~
a.cc: In function 'long long int readlong()':
a.cc:22:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   22 |         register long long x = 0, flag = 1;
      |                            ^
a.cc:22:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   22 |         register long long x = 0, flag = 1;
      |                                   ^~~~
a.cc:23:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |         register char ch;
      |                       ^~
a.cc: In function 'int main()':
a.cc:61:27: error: no matching function for call to 'max(int&, double&)'
   61 |                 maxx = max(maxx, a[i]);
      |                        ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:6:
/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:61:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   61 |                 maxx = max(maxx, 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:
/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:61:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |                 maxx = max(maxx, a[i]);
      |                        ~~~^~~~~~~~~~~~