Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3c48b3

Browse files
committed
Time: 256 ms (92.68%), Space: 94.4 MB (76.55%) - LeetHub
1 parent 1e9873e commit d3c48b3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
class Solution {
2+
public:
3+
#define db1(x) cout<<#x<<" = "<<x<<'\n'
4+
#define db2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<'\n'
5+
#define db3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<'\n'
6+
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
7+
#define p2darray(a, n, m) rep(i, 0, n){rep(j, 0, m){cout<<a[i][j]<<" ";}cout<<endl;}
8+
#define dv(v) {cout<<#v<<" = [" ; for (auto x : v) cout << x << " , "; cout <<" ]"<< nl ; }
9+
#define d2dv(v) { cout<<#v<<":"<<nl ; for (auto &x : v) { for (auto y : x) { cout << y << " "; } cout << nl; } }
10+
11+
12+
long long minimumTime(vector<int>& time, int totalTrips) {
13+
14+
15+
16+
17+
long long low = 0, high = 1e16;
18+
while (low < high) {
19+
long long mid = (low + high) / 2;
20+
long long ans = 0;
21+
for (auto i: time) {
22+
ans += mid / i;
23+
if (ans > totalTrips)break;
24+
}
25+
26+
if (ans >= totalTrips)
27+
high = mid;
28+
else
29+
low = mid + 1;
30+
}
31+
return low;
32+
33+
34+
35+
36+
37+
}
38+
};

0 commit comments

Comments
 (0)