Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main(void) {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- long long n, t;
- cin >> n >> t;
- vector<long long> machines;
- long long biggest = 0;
- for (long long i = 0; i < n; ++i) {
- long long temp;
- cin >> temp;
- machines.push_back(temp);
- if (temp > biggest) biggest = temp;
- }
- long long lbound = 0, ubound = t*biggest, mid;
- long long ans = 0;
- while (lbound <= ubound) {
- mid = (lbound+ubound)/2;
- int time = 0;
- for (long long i = 0; i < n; ++i) {
- time += mid/machines[i];
- }
- if (time == t) {
- ans = mid;
- break;
- } else if (time < t) {
- lbound = mid+1;
- } else {
- ans = mid;
- ubound = mid-1;
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement