Supply
TCO04 Wildcard · 2004-09-07 · by lars2520
Problem Statement
A
Notes
- The location of the new factory must have integral coordinates.
- There may be multiple factories or stores at the same location.
- The constraints ensure that the return is unique.
Constraints
- stores will contain between 1 and 10 elements, inclusive.
- factories will contain between 1 and 4 elements, inclusive.
- Each X and Y in stores and factories will be between 0 and 10, inclusive.
- Each CAPACITY and DEMAND will be between 1 and 10, inclusive.
- There will be no extraneous leading zeros or extra spaces in either input.
- The total DEMAND will exceed the total CAPACITY.
- The location providing the minimum cost will be unique, and there will be no other locations that have costs within 1E-3*C of that minimum.
{"4 0 10"}
{"5 0 7","10 0 8"}
Returns: { 10, 0 }
There are two stores, with demands of 7 and 8. The single existing factory has a capacity of 10, so our new factory must have a capacity of 5. The best place to put the factory is (10,0), the same spot as the store. Then, we have to ship 3 units from the existing factory to (10,0), and 7 units to (5,0). Thus, our total cost is 7*1*C + 3*6*C = 25*C.
{"0 0 1"}
{"5 5 7","10 10 8","10 0 5"}
Returns: { 7, 6 }
Notice that the optimal factory placement is not always at the same location as a store. The total cost here is about 92.485*C.
{"0 0 10","0 10 10","10 0 10","10 10 10"}
{"0 0 8",
"1 1 8",
"2 2 4",
"3 3 9",
"4 4 9",
"5 5 8",
"6 6 1",
"7 7 5",
"8 8 2",
"9 9 10"}
Returns: { 3, 3 }
{"0 0 1"}
{"10 10 10"}
Returns: { 10, 10 }
{"0 0 10","1 1 10","1 0 10","0 1 10"}
{"0 10 9",
"0 9 10",
"0 8 10",
"1 10 10",
"1 9 10",
"1 8 10",
"2 10 10",
"2 9 10",
"2 8 10",
"3 10 10"}
Returns: { 2, 10 }
Submissions are judged against all 45 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Supply with a public method vector<int> newFactory(vector<string> factories, vector<string> stores) · 45 test cases · 2 s / 256 MB per case