Optimal Strategy for the ICPC
Time limit1sMemory limit128 MB
Given up to 15 problem solving times, schedule them on three parallel workers within 300 minutes to maximize solved count, then minimize total completion-time penalty, with lexicographically smallest order.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Bit manipulation, Sorting, Greedy
- Solved
- No attempts yet
Problem
A three-member team competes in an ICPC-style programming contest. The contest lasts exactly 300 minutes.
The team's score is the sum, over every solved problem, of the time consumed for that problem. The time consumed for a solved problem is the number of minutes from the start of the contest to the submission of its first accepted run, plus 20 penalty minutes for each previously rejected run of that problem. A problem that is not solved contributes nothing.
One element of the optimal strategy is simply to make no incorrect submissions, so the team never has to worry about penalty minutes. All that remains is to decide the order in which the problems are submitted.
Assume the team can estimate the development time required for each problem exactly. The three members each think about a different problem rather than all working on the same one, each member types infinitely fast, and no member uses a terminal while thinking. Hence up to three problems can be in progress at the same time, and all three members may even submit a problem within the same minute.
A problem counts as solved only if it is submitted within the 300 minutes of the contest. Determine a strategy that solves the greatest number of problems and, among those, achieves the best (smallest) possible score. If several strategies solve the same number of problems with the same score, report the submission order that comes first lexicographically.
Input
The first line contains a single integer (), the number of data sets — one per set of problems. Each of the following lines describes one data set. The line begins with an integer (), the number of problems in that data set, followed by integers between and inclusive, giving the estimated time required to solve each problem. The problems are labeled with the uppercase letters in the order given. The contest lasts exactly minutes.
Output
For each data set, print one line containing, in order: the text Data set X: (where is the data set number starting from ), the labels of the solved problems in the order they are submitted, the total number of problems solved, and the final penalty score. All entries on a line are separated by single spaces.