GoncaSoft is an internet company that runs many services and has
When GoncaSoft plans to launch a new service
Input Specification
The first line of the input contains two space-separated integers
Output Specification
Output one line containing
Constraints
and .- Each data center has at most
machines initially. for each service such that . , for each service such that . The data centers will always have enough machines for the new services.
Subtasks
- Subtask 1 (12 points):
, . - Subtask 2 (12 points):
, . - Subtask 3 (9 points):
, . - Subtask 4 (26 points): Each data center has initially at most
machines. - Subtask 5 (18 points):
for all services from to . - Subtask 6 (23 points): No further constraints.
Sample Input
5 4
20 12 10 15 18
3 4
4 1
1 3
4 2
Sample Output
11 10 10 9 8
Explanation
Step | Available Machines | Operations |
---|---|---|
Beginning | 20 12 10 15 18 | |
Service #1: before launching | 20 18 15 12 10 | Sort the data centers in descending order. |
Service #1: after launching | 17 15 12 9 10 | Use 3 machines in each of the top 4 data centers. |
Service #2: before launching | 17 15 12 10 9 | Sort the data centers in descending order. |
Service #2: after launching | 13 15 12 10 9 | Use 4 machines in the top data center. |
Service #3: before launching | 15 13 12 10 9 | Sort the data centers in descending order. |
Service #3: after launching | 14 12 11 10 9 | Use 1 machine in each of the top 3 data centers. |
Service #4: before launching | 14 12 11 10 9 | Sort the data centers in descending order. |
Service #4: after launching | 10 8 11 10 9 | Use 4 machines in each of the top 2 data centers. |
End | 11 10 10 9 8 | Sort the data centers in descending order. |
Comments