-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3079.cpp
More file actions
42 lines (32 loc) · 699 Bytes
/
3079.cpp
File metadata and controls
42 lines (32 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define MAXN 100050
long long N,M,ans;
long long t[MAXN];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> N >> M;
for(int i=0 ; i<N ; i++){
cin >> t[i];
}
long long low = 0, high = 1e18;
while(high>=low){
long long mid = (low + high)/2;
long long sum = 0;
for(int i=0 ; i<N ; i++) {
sum += mid / t[i];
if(sum >= M) break;
}
if(sum >= M){
ans = mid;
high = mid-1;
} else {
low = mid + 1;
}
}
cout << ans;
}