#GD0000195. Giảm khối lượng công việc (Work Reduction)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Giảm khối lượng công việc (Work Reduction)
Work Reduction
Source: UVa
Version: Phuoc Hung OJ (single-case adaptation where applicable)
Problem Statement
You have units of work and must reduce them to exactly , . Each of agencies has a record NAME:A,B: it charges to decrease the workload by one, or to reduce the current workload to its floor half. Going below is not allowed. Compute the minimum total cost for each agency, then list agencies by increasing cost, breaking ties by lexicographic name.
Input
Line 1 contains . Each of the next lines is NAME:A,B, where NAME is 1–16 distinct uppercase Latin letters, unique among agencies, and are nonnegative integers. This PHOJ version has one case.
Output
Print exactly lines, each containing the agency name, a space, and its optimal cost. Do not print the original multi-case Case i prefix.
Subtasks
- Subtask 1 (20 points): ; ; ; all names are unique uppercase strings of length 1–16.
- Subtask 2 (30 points): ; ; ; all names are unique uppercase strings of length 1–16.
- Subtask 3 (50 points): ; ; ; all names are unique uppercase strings of length 1–16.
Examples
Example 1
Input
100 5 3
A:1,10
B:2,5
C:3,1
Output
C 7
B 22
A 37
Explanation
Agency C can use inexpensive halvings, costing 7 in total. B costs 22 and A costs 37. They are listed as C, B, A.
Example 2
Input
1123 1122 3
B:50,300
A:1,1000
E:0,0
Output
E 0
A 1
B 50
Explanation
Only one unit needs to be removed. E charges 0, A charges 1, and B charges 50, so this is the required order.