CircleMarket
SRM 481 · 2010-03-12 · by vexorian
Problem Statement
Return the total number of purchases you will make.
Constraints
- openTime will contain between 2 and 50 elements, inclusive.
- closeTime will contain the same number of elements as openTime.
- travelTime will be between 1 and 1000000, inclusive.
- Each element of openTime will be between 0 and 999999, inclusive.
- Element i of closeTime will be between openTime[i]+1 and 1000000, inclusive.
{0, 0, 0}
{100, 100, 100}
3
Returns: 3
{45, 45, 0}
{50, 50, 20}
15
Returns: 1
The first time stores 0 and 1 are visited, they will be closed. Store 2 can only be visited after 30 seconds which is after its closing time. Store 0 will be open the next time it is visited at 45 seconds. The second time store 1 is visited the time will be 60 seconds and it will be closed.
{1000, 1000}
{1010, 1010}
1
Returns: 2
The stores will be closed for the first 500 visits. The 501-th time you visit each of the stores, they will finally be open.
{999999, 2, 4}
{1000000, 22, 44}
2
Returns: 2
{363, 237, 382, 232, 392, 3829, 99999, 12}
{365, 1239, 2384, 234, 394, 3831, 100001, 15}
3
Returns: 3
Submissions are judged against all 136 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CircleMarket with a public method int makePurchases(vector<int> openTime, vector<int> closeTime, int travelTime) · 136 test cases · 2 s / 256 MB per case