RoadWork
TCCC '03 NE/SE Regional · 2003-02-18 · by dgoodman
Problem Statement
We want a program that will examine the contracts and will tell us how
many feet of highway have been included in more than one contract. Create
a class RoadWork that contains a method fraudFeet that takes
Notes
- Keep in mind that the highways can potentially be very long (2,000,000,000 feet) and that your program must run in 8 seconds, and use less than 64 MB of memory.
Constraints
- start contains between 1 and 50 elements inclusive
- end contains the same number of elements as start
- each element of end is greater than the corresponding element of start
- each element of start and end is between 0 and 2,000,000,000 inclusive
{50,50,50}
{58,58,60}
Returns: 8
All three contracts cover the section from 50 to 58
{171234,12,20,30}
{171236,20,30,40}
Returns: 0
{12,32,92}
{991,161,1093}
Returns: 959
32 to 92 is covered by the first 2 contracts, 92 to 161 is covered by all the contracts, and 161 to 991 is covered by the first and last contract. The answer is (92-32) + (161-92) + (991-161)
{2,1,3}
{3,3,7}
Returns: 1
{75,175,275}
{180,178,1000}
Returns: 3
Submissions are judged against all 82 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RoadWork with a public method int fraudFeet(vector<int> start, vector<int> end) · 82 test cases · 2 s / 256 MB per case