Skip to content

Commit cd50d7e

Browse files
committed
Runtime: 743 ms (Top 16.20%) | Memory: 101.5 MB (Top 46.24%)
1 parent 919ff08 commit cd50d7e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
// Runtime: 743 ms (Top 16.20%) | Memory: 101.5 MB (Top 46.24%)
12
class Solution
23
{
34
bool canReachInTime(const vector<int>& dist, const double hour, int speed)
45
{
56
double time = 0;
67
for (int i = 0; i < dist.size() - 1; ++i)
78
time += ((dist[i] + speed - 1) / speed);
8-
9+
910
time += ((double)dist.back()) / speed;
1011
return time <= hour;
1112
}
12-
13+
1314
public:
1415
int minSpeedOnTime(vector<int>& dist, double hour)
1516
{
1617
int N = dist.size();
1718
if (hour <= (double)(N - 1))
1819
return -1;
19-
20+
2021
int lo = 1, hi = 1e7, mi;
2122
while (lo < hi)
2223
{
@@ -26,7 +27,7 @@ class Solution
2627
else
2728
lo = mi + 1;
2829
}
29-
30+
3031
return hi;
3132
}
32-
};
33+
};

0 commit comments

Comments
 (0)