BasicSorting
TCCC05 Finals · 2005-01-10 · by lars2520
Problem Statement
Notes
- No two files are 'equal' -- one of them always belongs strictly after the other in the ordering.
Constraints
- sizes will contain between 2 and 6 elements, inclusive.
- Each element of sizes will be between 1 and 100, inclusive.
{1,2,3}
Returns: 11
With 3 files, you must compare all 3 pairs of files to figure out the order. The total time is thus 1*2 + 1*3 + 2*3 = 11 minutes.
{1,1,1,1}
Returns: 5
One way to do this is to find the order on three of the files, which takes 3 minutes. Then, compare the fourth file to the middle one of those three files. Finally, if the fourth file comes after the middle file, compare it to the last file, while if it comes before the fourth file, compare it to the first file.
{15,74,61,34,21}
Returns: 12477
{1,2,3,4,5,6}
Returns: 128
{1,1,1,1,1,1}
Returns: 10
Submissions are judged against all 77 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class BasicSorting with a public method int minSortTime(vector<int> sizes) · 77 test cases · 2 s / 256 MB per case