Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- const int maxn = 33;
- ll a[maxn];
- int n;
- ll K;
- bool check(ll x) {
- ll res = 0;
- for(int i = 0; i < n; i++) {
- res += x / a[i];
- }
- if(res >= K){
- return true;
- }
- return false;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin >> n >> K;
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- }
- ll L = 0, R = 1e18;
- ll res = 2e18;
- while(L <= R) {
- ll mid = (L + R) / 2;
- if(check(mid)) {
- res = min(res, mid);
- R = mid - 1;
- }
- else {
- L = mid + 1;
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement