CF1846C Rudolf and the Another Competition
题目描述
Rudolf 已经报名了一个遵循 ICPC 规则的编程竞赛。这些规则意味着,每通过一道题,参与者将获得 $1$ 积分,同时还会受到相当于从比赛开始到 AC 时间的罚时。在排行榜中,分数高的参与者排名较高,如果分数相等,罚时较少的参与者排名较高。
现在总共有 $n$ 名参与者参与了比赛,Rudolf 是编号为 $1$ 的参与者。已知一共有 $m$ 题,$h$ 分钟。
现在,一个强大的人工智能已经预测到了值 $t_{i,j}$,它表示第 $i$ 位参与者解决第 $j$ 道问题所需的分钟数。
Rudolf 意识到解决问题的顺序可以影响最终的结果。例如,如果 $h = 120$,解决问题的时间是\[ $20,15,110$ \],那么,如果 Rudolf 按一下几种顺序解决问题,会出现一下几种情况:
- ${3,1,2}$,那么他只会解决第三个问题,得到 $1$ 积分和 $110$ 罚时。
- ${1,2,3}$,那么他将在开始的 $20$ 分钟后解决第一个问题,在 $20+15=35$ 分钟后解决第二个问题,他将没有时间解决第三个问题。因此,他将获得 $2$ 积分和 $20+35=55$ 罚时。
- ${2,1,3}$,那么他将在开始的 $15$ 分钟后解决第二个问题,在 $15+20=35$ 分钟后解决第一个问题,他将没有时间解决第三个问题。因此,他将获得 $2$ 点和 $15+35=50$ 的罚时。
Rudolf 感兴趣的是,如果每个参与者根据人工智能的预测,以最佳顺序解决问题,他将在比赛中为第几名。假设在积分和罚时相同的情况下,Rudolf 将占据最靠前的位置。
输入格式
第一行包含一个整数 $t$($1\le t\le 10^3$)——测试用例的数量。
然后遵循测试用例的描述。
每个测试用例的第一行包含三个整数 $n,m,h$($1\le n\cdot m\le 2\cdot 10^5,1\le h\le 10^6$)——分别是参赛人数、问题数量和比赛时长。
然后是 $n$ 行,每一行包含 $m$ 整数 $t_{i,j}$($1\le t_{i,j}\le 10^6$)——第 $i$ 个参与者解决第 $j$ 个问题所需要的时间(单位:分钟)。
保证所有测试数据的 $n\cdot m$ 的总和不超过 $2\cdot 10^5$ 的总和。
输出格式
对于每组数据,输出一个整数——如果所有参与者以最佳顺序解决问题,Rudolf 在最终表格中的位置。
## 样例解释
在第一组数据中,Rudolf 将得到 $2$ 积分和 $50$ 分钟的处罚。第二个参与者将只解决一个问题,并获得 $1$ 积分和 $90$ 分钟的罚时。第三名参与者将解决所有问题,并获得 $3$ 积分和 $240$ 分钟的罚时。因此,Rudolf 将获得第二名。
在第二组数据中,两个参与者都将获得 $1$ 积分和 $30$ 分钟的罚时。因为分数相等,Rudolf 会得到更靠前的排名,所以他会获得第一名。
在第三个例子中,Rudolf 是唯一的参与者,因此他将占据第一位。
在第四个例子中,所有参与者都可以解决两个问题,罚时分别为 $25 = 8+(8+9)$、$24 = 7+(7+10)$ 和 $26 = 8 + (8 + 10)$。因为罚时不同,所以第二个参与者获得第一名,Rudolf 获得第二名。
说明/提示
In the first example, Rudolf will get $ 2 $ points and $ 50 $ penalty minutes. The second participant will solve only one problem and get $ 1 $ point and $ 90 $ penalty minutes. And the third participant will solve all $ 3 $ problems and get $ 3 $ points and $ 240 $ penalty minutes. Thus, Rudolf will take the second place.
In the second example, both participants will get $ 1 $ point and $ 30 $ penalty minutes. In case of a tie in points, Rudolf gets the better position, so he will take the first place.
In the third example, Rudolf is the only participant, so he will take the first place.
In the fourth example, all participants can solve two problems with penalty of $ 25 = 8 + (8 + 9) $ , $ 24 = 7 + (7 + 10) $ and $ 26 = 8 + (8 + 10) $ , respectively, thanks to the penalty, the second participant gets the first place, and Rudolf gets the second.