#P6260. [ICPC2019 WF] Miniature Golf
[ICPC2019 WF] Miniature Golf
题目背景
Warning: If you submit a malicious program, you will be banned.
警告:恶意提交本题将被封号。
题目描述
A group of friends has just played a round of miniature golf. Miniature golf courses consist of a number of holes. Each player takes a turn to play each hole by hitting a ball repeatedly until it drops into the hole. A player's score on that hole is the number of times they hit the ball. To prevent incompetent players slowing down the game too much, there is also an upper limit (a positive integer) on the score: if a player has hit the ball times without the ball dropping into the hole, the score for that hole is recorded as and that player's turn is over. The total score of each player is simply the sum of their scores on all the holes. Naturally, a lower score is considered better.
There is only one problem: none of the players can remember the value of the integer . They decide that they will not apply any upper limit while playing, allowing each player to keep playing until the ball drops into the hole. After the game they intend to look up the value of and adjust the scores, replacing any score on a hole that is larger than with .
The game has just finished, but the players have not yet looked up . They wonder what their best possible ranks are. For this problem, the rank of a player is the number of players who achieved an equal or lower total score after the scores are adjusted with . For example, if the adjusted scores of the players are and , then their ranks are and respectively.
Given the scores of the players on each hole, determine the smallest possible rank for each player.
输入格式
The first line of input contains two integers and , where is the number of players and is the number of holes. The next lines each contain positive integers. The number on the of these lines is the score for player on hole , and does not exceed .
输出格式
Output a line with the minimum possible rank for each player, in the same order as players are listed in the input.
题目大意
题目描述
几个朋友玩了一场小型的高尔夫。这种小型的高尔夫是由若干个洞组成的。每个玩家轮流玩这个游戏,不停地击球直到球落到每个洞里。玩家在一个洞上的得分是他击球的次数。为了防止捣乱的玩家把游戏速度放慢太多,游戏规则中也会给一个上限(一个正整数)来控制分数:如果一个玩家在一个洞上已经击球次,但是球还没有落到洞里,那么这个玩家在这个洞上的得分就是,并且这个玩家的回合就结束了。一个玩家的总得分就是他在各个洞上的得分之和。自然地,在这个游戏中,分越低越好。
但是有一个问题:没有玩家记得的值。玩家们决定在玩的时候不设置的值,允许每个玩家不断击球,直到球掉到洞里。玩完游戏,他们准备设置的值,并更改那些在洞上的分数大于的值。
游戏结束了,但他们还没有设置。他们想知道自己的最佳排名是什么。一个人的排名是在所有人中,得分比这个人低或和这个人相等的人数(包含自己)。比如,当五个人的得分分别是 ,那么他们的排名就是 。
给你每个玩家在每个洞上的得分,为每一个玩家求出最小的可能的排名。
输入格式
第一行:两个整数 和 ,()是玩家个数,()是洞的个数。
接下来行,每行个正整数,第行第列的数表示第个玩家在第个洞上的得分,这些数都不会超过。
输出格式
输出 行,每行一个正整数,第 行表示第 个玩家的最小排名。
说明/提示
来源:ICPC World Finals 2019 Problem J
题目名称:Miniature Golf
3 3
2 2 2
4 2 1
4 4 1
1
2
2
6 4
3 1 2 2
4 3 2 2
6 6 3 2
7 3 4 3
3 4 2 4
2 3 3 5
1
2
5
5
4
3
提示
Source: ICPC World Finals 2019 Problem J: Miniature Golf.