#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,m,snack[1000005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i=0; i<m; i++) {
cin >> snack[i];
}
int st=1;
int en= *max_element(snack, snack+m);
int ans=0;
while(st<=en) {
int mid=(st+en)/2;
int cnt=0;
for(int i=0; i<m; i++) {
if(snack[i]>=mid) {
cnt+=snack[i]/mid;
}
}
if(cnt>=n) {
ans=mid;
st=mid+1;
}
else en=mid-1;
}
cout << ans;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: