#SP0000238. Người sống sót cuối cùng (Last Man Standing)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Người sống sót cuối cùng (Last Man Standing)
Last Man Standing
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are heroes. Hero starts with health and armor (current armor initially equals ). Before each game, choose a fixed positive integer damage value . In every round, all living heroes simultaneously take damage.
- If current armor is strictly greater than , subtract from the armor, leaving health unchanged.
- Otherwise, subtract from health and reset current armor to the initial value .
A hero dies when health reaches zero. The game ends when every hero has died. A unique last hero earns the number of rounds during which that hero was the only survivor; all other heroes earn zero. If multiple heroes die in the final round, everyone gets zero.
Play the game separately for every positive integer , resetting the heroes each time. Find the maximum score each hero can achieve in any game.
Input
- The first line contains integer , the number of heroes.
- The second line contains exactly integers .
- The third line contains exactly integers .
Output
Print integers in one line; the -th is hero 's maximum score over all positive damage values .
Subtasks
-
Subtask 1 (20 points): ; , for all .
-
Subtask 2 (30 points): ; , for all .
-
Subtask 3 (50 points): ; , for all .
Examples
Input
3
3 1 2
3 11 5
Output
1 1 1
Explanation
The pairs are , , and . For fixed , hero loses one health every rounds and dies at time .
At , death times are , so hero 2 gets . At they are , so hero 3 gets . At they are , so hero 1 gets . For the remaining damage values, gives , gives , and gives . Values all yield , while every yields . No case gives any hero more than one point, and each hero attains exactly one in some game. Hence output 1 1 1.