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