#BS0000169. R2D2 và đội quân người máy (R2D2 and Droid Army)
Bài tập thuộc lộ trình
Mục lục đề ⌄
R2D2 và đội quân người máy (R2D2 and Droid Army)
R2D2 and Droid Army
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are droids in a row, numbered from to . Each has types of components. Droid contains components of type .
R2D2 has a weapon for each type. One shot with weapon destroys one component of type on every droid that still has such a component. A droid is destroyed when all its components are destroyed.
R2D2 can fire at most shots in total. Choose how many shots to fire from each weapon in order to destroy a longest consecutive block of droids. If several optimal choices exist, output any of them. It is not necessary to use all shots.
Input
- The first line contains integers : number of droids, component types and available shots.
- Each of the next lines contains integers , the component counts of the corresponding droid.
Output
Print exactly nonnegative integers , the shots fired by each weapon. The sum must satisfy ; the choice must destroy a consecutive block of maximum achievable length.
Subtasks
- Subtask 1 (20 points): ; ; ; for all , .
- Subtask 2 (30 points): ; ; ; for all , .
- Subtask 3 (50 points): ; ; ; for all , .
Examples
Input
5 2 4
4 0
1 2
2 1
0 2
1 3
Output
2 2
Explanation
There are two weapon types and the budget is four shots. Fire two shots of each type, consuming shots.
- Droid has components, so it is destroyed.
- Droid has components, so it is destroyed.
- Droid has components, so it is destroyed.
- Droid still has two components of type ; droid still has one component of type .
Droids through form a destroyed block of length . No block of length can be destroyed within four shots, so this choice is optimal.