Skip to content

Commit b9aa657

Browse files
committed
Runtime: 736 ms (Top 18.65%) | Memory: 94.5 MB (Top 68.73%)
1 parent 00dca7a commit b9aa657

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1+
// Runtime: 736 ms (Top 18.65%) | Memory: 94.5 MB (Top 68.73%)
12
class Solution {
23
public:
34
long long minimumTime(vector<int>& time, int totalTrips) {
45
long long anstillnow=-1;
5-
6-
long long left=1, right= 100000000000001; //can also write this as 1+1e14
7-
6+
7+
long long left=1, right= 100000000000001; //can also write this as 1+1e14
8+
89
while(left<=right){
9-
long long mid= left+ (right-left)/2; // find mid point like this to avoid overflow
10+
long long mid= left+ (right-left)/2; // find mid point like this to avoid overflow
1011
long long curr_trips=0;
1112
for(int t: time){
1213
curr_trips+= mid/t;
1314
}
14-
15-
if(curr_trips>=totalTrips){
15+
16+
if(curr_trips>=totalTrips){
1617
anstillnow=mid;
1718
right=mid-1;
1819
}
19-
20+
2021
else{
2122
left=mid+1;
2223
}
2324
}
24-
25+
2526
return anstillnow;
2627
}
27-
};
28+
};

0 commit comments

Comments
 (0)