time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
In the game show "Ten Words of Wisdom", there are n� participants numbered from 11 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 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?
Input
The first line contains a single integer t� (1≤t≤1001≤�≤100) — the number of test cases.
The first line of each test case contains a single integer n� (1≤n≤501≤�≤50) — the number of responses.
Then n� lines follow, the i�-th of which contains two integers ai�� and bi�� (1≤ai,bi≤501≤��,��≤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��≤10, and all values of bi�� are distinct.
Output
For each test case, output a single line containing one integer x� (1≤x≤n1≤�≤�) — 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.
Example
input
Copy
3
5
7 2
12 5
9 3
9 4
10 1
3
1 2
3 4
5 6
1
1 43
output
Copy
4 3 1
Note
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.文章来源:https://www.toymoban.com/news/detail-644794.html
解题说明:水题,直接遍历,找出第一个数不超过10,并且第二个数最大的组合即可。文章来源地址https://www.toymoban.com/news/detail-644794.html
#include<stdio.h>
int main()
{
int t, k, w;
scanf("%d", &t);
for (k = 0; k < t; k++)
{
int i, n, max = 0, a, b;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d%d", &a, &b);
if (a <= 10 && b > max)
{
max = b;
w = i;
}
}
printf("%d\n", w + 1);
}
return 0;
}
到了这里,关于B. Ten Words of Wisdom的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!