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.
---------------------------------------------------
游戲節(jié)目“智慧十句話”中,有n位參與者,編號為1到n,每人提交一個答案。 第 i 個響應的長度為 ai,質量為 bi。 沒有兩個響應具有相同的質量,并且至少一個響應的長度最多為 10。
該節(jié)目的獲勝者是所有不超過 10 個字的回復中質量最高的回復。 哪一個反應是獲勝者?
輸入
第一行包含一個整數(shù) t (1≤t≤100) — 測試用例的數(shù)量。
每個測試用例的第一行包含一個整數(shù) n (1≤n≤50) — 響應數(shù)。
然后n
? 接下來的行,其中第 i 行包含兩個整數(shù) ai 和 bi (1≤ai,bi≤50) — 分別是單詞數(shù)和第 i 個響應的質量。
對輸入的附加約束:在每個測試用例中,至少有一個 i 值滿足 ai≤10,并且 bi 的所有值都是不同的。
輸出
對于每個測試用例,根據語句中給出的規(guī)則,輸出一行,其中包含一個整數(shù) x (1≤x≤n) — 節(jié)目的獲勝者。
可以證明,根據語句中的約束,每個測試用例恰好存在一個獲勝者。
-------------------------------------
下面是代碼: