B. Ten Words of Wisdom

这篇具有很好参考价值的文章主要介绍了B. Ten Words of Wisdom。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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.

解题说明:水题,直接遍历,找出第一个数不超过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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 年轻不乏野心,想做年薪40万+的软件测试工程师?写给长途漫漫中的你...

    本人从事自动化测试10年多,之前在猪场工作,年薪突破40W+,算是一个生活过得去的码农。(仅代表本人) 目前从事自动化测试的薪资待遇还是很不错的,所以如果朋友们真的对自动化感兴趣的话可以坚持学下去,我也很乐意行业中出现更多能力出众的小伙伴们。 今天来给

    2023年04月27日
    浏览(41)
  • 蓝桥杯1024第 2 场算法双周赛题解+Ac代码

    提醒:篇幅可能有点长,为了方便,大家可以直接看目录快速查找想要的内容 1.新生【算法赛】 - 蓝桥云课 (lanqiao.cn) input: output: 1.对于每一块地板,如果能被凑出来,那么一定是2*3地砖组合出来的,无论2*3地砖怎么放都为6的倍数,故长为n,宽为m的地板,n*m%6==0一定成立 2.这里

    2024年02月06日
    浏览(31)
  • 【算法&数据结构体系篇class32】:IndexTree & AC自动机

    特点: 1 )支持区间查询 2 )没有线段树那么强,但是非常容易改成一维、二维、三维的结构 3 )只支持单点更新   解决在一个大字符串中,找到多个候选字符串的问题   AC 自动机算法核心 : 1 )把所有匹配串生成一棵前缀树 2 )前缀树节点增加 fail 指针 3 ) fail 指针的含

    2023年04月25日
    浏览(34)
  • 【算法设计与分析】经典常考三十三道例题&AC代码

    ❥ 小虾目前大三,我校在大一下开设《数据结构》这门课,大二上开了《算法设计与分析》这门课,很庆幸这两门课的上机考试总成绩一门100,一门99,最后总分也都90+。下文会给出机试的33道题目&AC代码&注释供大家参考。 ❥ 《算法设计与分析》用的是屈婉玲老师的教材

    2024年02月09日
    浏览(27)
  • B. Taisia and Dice

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Taisia has n� six-sided dice. Each face of the die is marked with a number from 11 to 66, each number from 11 to 66 is used once. Taisia rolls all n� dice at the same time and gets a sequence of values a1,a2,…,an�1,�2,…,�� 

    2024年02月10日
    浏览(25)
  • B. Sets and Union

    输入 输出 4 5 6 0         这里题目的意思是,要求合并尽可能多的集合,使它的集合大小最大,但是不能等于全部集合的合并。         这里由于题目所给的范围较小,所以我们可以暴力枚举,其次,里面也有贪心的成分,这里我们换个思路,我们通过总的集合,根据总的

    2024年02月07日
    浏览(31)
  • B. 用人工智能来拍摄变焦风景照片

    作者:禅与计算机程序设计艺术 在现代社会,数字化革命正席卷全球,越来越多的人开始使用智能手机、平板电脑等移动设备来浏览互联网,拍摄照片、视频、短视频和音乐等视听媒体。然而,由于手机拍摄器件的限制,导致照片过分模糊、缺少明显肉眼可见的特征,使得它

    2024年02月06日
    浏览(35)
  • CF 1823B B. Sort with Step

    Problem - B - Codeforces 给n长的数组,里边只有1-n的数字,问你能不能在k步长的交换内换成升序的1-n 首先给你1-n的数字还要排成增序; 对于3 4 1 2 3在第1个数, abs(3 - 1) % 2 == 0; 所以3可以在步长为2的交换中换回位置3 对于步长为2 , 如果你在1的位置,所有你能换的就是1 3 5 7 …

    2024年02月01日
    浏览(21)
  • 【id:57】【20分】B. 银行账户(静态成员与友元函数)

    时间限制 1s 内存限制 128MB 题目描述 银行账户类的基本描述如下: class Account { private: static float count; // 账户总余额 static float interestRate; string accno, accname; float balance; public: Account(string ac, string na, float ba); ~Account(); void deposit(float amount); // 存款 void withdraw(float amount); // 取款 float

    2024年02月02日
    浏览(26)
  • 【CF闯关练习】—— 1400分(C. Make Good、B. Applejack and Storages)

    🌏博客主页: PH_modest的博客主页 🚩当前专栏: cf闯关练习 💌其他专栏: 🔴 每日一题 🟡 C++跬步积累 🟢 C语言跬步积累 🌈座右铭: 广积粮,缓称王! 👉传送门👈 XOR运算就是按位异或:相同为0,不同为1 这个操作符有两个结论: X ⊕ X = 0 Xoplus X= 0 X ⊕ X = 0 0 ⊕ X = X

    2024年01月21日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包