#P9321. [EGOI 2022] Data Centers / 数据中心
[EGOI 2022] Data Centers / 数据中心
Background
Day 2 Problem A.
Translated from EGOI2022 datacenters.
Problem Description
Gonka Software (Gongsoft) is an Internet company that runs many services and has data centers around the world. Each data center has some available machines. For security and redundancy reasons, each service runs with one or more replicas at the same time. Each replica runs in a different data center and needs some machines to run. All replicas of one service require the same number of machines.
When Gongsoft plans to launch a new service that needs replicas, with each replica running on machines, it sorts the data centers in descending order by the number of currently available machines, and then uses machines in each of the first data centers.
Output the number of machines remaining in each data center after launching services.
Input Format
The first line contains two integers , representing the number of data centers and the number of services.
The second line contains integers , representing the initial number of available machines in each data center.
The next lines each contain two integers , representing the required number of machines and the number of replicas.
Output Format
Output one line with integers in descending order, representing the number of machines remaining in each data center.
5 4
20 12 10 15 18
3 4
4 1
1 3
4 2
11 10 10 9 8
Hint
Sample explanation
| Step | Remaining machines | Operation |
|---|---|---|
| Initial | ||
| Before service | Sort data centers in descending order | |
| After service | Use machines in each of the first data centers | |
| Before service | Sort data centers in descending order | |
| After service | Use machines in the st data center | |
| Before service | Sort data centers in descending order | |
| After service | Use machine in each of the first data centers | |
| Before service | Sort data centers in descending order | |
| After service | Use machines in each of the first data centers | |
| End | Sort data centers in descending order |
Constraints
For all testdata, , , , , . It is guaranteed that at any time, the number of available machines in any data center is non-negative.
- Subtask 1 ( points): , .
- Subtask 2 ( points): , .
- Subtask 3 ( points): , .
- Subtask 4 ( points): .
- Subtask 5 ( points): .
- Subtask 6 ( points): No additional constraints.
Translated by ChatGPT 5
