CF 1850A - To My Critics
In the game show "Ten Words of Wisdom", there are n participants numbered from 1 to n, each of whom submits one response. The i-th response is ai words long and has quality bi. No two responses have the same quality, and at least one response has length at most 10.
The winner of the show is the response which has the highest quality out of all responses that are not longer than 10 words. Which response is the winner?
Input
The first line contains a single integer t (1≤t≤100) — the number of test cases.
The first line of each test case contains a single integer n (1≤n≤50) — the number of responses.
Then n
lines follow, the i-th of which contains two integers ai and bi (1≤ai,bi≤50) — the number of words and the quality of the i-th response, respectively.
Additional constraints on the input: in each test case, at least one value of i satisfies ai≤10, and all values of bi are distinct.
Output
For each test case, output a single line containing one integer x (1≤x≤n) — the winner of the show, according to the rules given in the statement.
It can be shown that, according to the constraints in the statement, exactly one winner exists for each test case.
---------------------------------------------------
游戏节目“智慧十句话”中,有n位参与者,编号为1到n,每人提交一个答案。 第 i 个响应的长度为 ai,质量为 bi。 没有两个响应具有相同的质量,并且至少一个响应的长度最多为 10。
该节目的获胜者是所有不超过 10 个字的回复中质量最高的回复。 哪一个反应是获胜者?
输入
第一行包含一个整数 t (1≤t≤100) — 测试用例的数量。
每个测试用例的第一行包含一个整数 n (1≤n≤50) — 响应数。
然后n
接下来的行,其中第 i 行包含两个整数 ai 和 bi (1≤ai,bi≤50) — 分别是单词数和第 i 个响应的质量。
对输入的附加约束:在每个测试用例中,至少有一个 i 值满足 ai≤10,并且 bi 的所有值都是不同的。
输出
对于每个测试用例,根据语句中给出的规则,输出一行,其中包含一个整数 x (1≤x≤n) — 节目的获胜者。
可以证明,根据语句中的约束,每个测试用例恰好存在一个获胜者。
-------------------------------------
下面是代码: