CF1850B.Ten Words of Wisdom

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the game show "Ten Words of Wisdom", there are nn participants numbered from 11 to nn, each of whom submits one response. The ii-th response is aia_i words long and has quality bib_i. No two responses have the same quality, and at least one response has length at most 1010.

The winner of the show is the response which has the highest quality out of all responses that are not longer than 1010 words. Which response is the winner?

在游戏节目《十词箴言》中,共有 nn 位参与者,编号从 11 到 nn,每人提交一个答案。第 ii 个答案长度为 aia_i 个单词,质量为 bib_i。任意两个答案的质量均不相同,且至少有一个答案的长度不超过 1010。

该节目的获胜者是所有长度不超过 1010 个单词的答案中质量最高的那个答案。请问哪个答案是获胜者?

输入格式

The first line contains a single integer tt (1≤t≤1001 \leq t \leq 100) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤501 \leq n \leq 50) — the number of responses.

Then nn lines follow, the ii-th of which contains two integers aia_i and bib_i (1≤ai,bi≤501 \leq a_i, b_i \leq 50) — the number of words and the quality of the ii-th response, respectively.

Additional constraints on the input: in each test case, at least one value of ii satisfies ai≤10a_i \leq 10, and all values of bib_i are distinct.

第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100)—— 表示测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤501 \leq n \leq 50)—— 表示回复的数量。

接下来是 nn 行,其中第 ii 行包含两个整数 aia_i 和 bib_i(1≤ai,bi≤501 \leq a_i, b_i \leq 50)—— 分别表示第 ii 条回复的字数和质量。

输入的额外约束:在每个测试用例中,至少存在一个下标 ii 满足 ai≤10a_i \leq 10,且所有 bib_i 的值互不相同。

输出格式

For each test case, output a single line containing one integer xx (1≤x≤n1 \leq x \leq 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.

对于每个测试用例,输出一行,包含一个整数 xx(1≤x≤n1 \leq x \leq n)——即根据题面中给出的规则所确定的节目获胜者。

可以证明:根据题面中的约束条件,每个测试用例均恰好存在唯一一个获胜者。

输入输出样例

  • 输入#1

    3
    5
    7 2
    12 5
    9 3
    9 4
    10 1
    3
    1 2
    3 4
    5 6
    1
    1 43

    输出#1

    4
    3
    1

说明/提示

In the first test case, the responses provided are as follows:

  • Response 1: 77 words, quality 22
  • Response 2: 1212 words, quality 55
  • Response 3: 99 words, quality 33
  • Response 4: 99 words, quality 44
  • Response 5: 1010 words, quality 11

We can see that the responses with indices 11, 33, 44, and 55 have lengths not exceeding 1010 words. Out of these responses, the winner is the one with the highest quality.

Comparing the qualities, we find that:

  • Response 1 has quality 22.
  • Response 3 has quality 33.
  • Response 4 has quality 44.
  • Response 5 has quality 11.

Among these responses, Response 4 has the highest quality.

在第一个测试用例中,提供的回复如下:

  • 回复 1:77 个单词,质量为 22
  • 回复 2:1212 个单词,质量为 55
  • 回复 3:99 个单词,质量为 33
  • 回复 4:99 个单词,质量为 44
  • 回复 5:1010 个单词,质量为 11

我们可以看出,索引为 11、33、44 和 55 的回复长度均不超过 1010 个单词。在这些回复中,胜出者是质量最高的那一个。

比较各回复的质量,我们得到:

  • 回复 1 的质量为 22。
  • 回复 3 的质量为 33。
  • 回复 4 的质量为 44。
  • 回复 5 的质量为 11。

在这些回复中,回复 4 的质量最高。

输入解题思路,AI测评打分。不知道怎么写?

首页