# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977391 | aykhn | Wiring (IOI17_wiring) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
int l = 0; int r = 1000000000;
int best = 0;
while (l <= r)
{
int mid = (l + r)/2; int c = 0;
if (mid == 0) {cout << 0 << endl; return 0;}
for (int i = 0; i < n; i++)
{
c += a[i]/mid;
}
if (c >= m)
{
best = max(best, mid);
l = mid + 1;
}
else r = mid - 1;
}
cout << best;
}