QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 512 MB 總分: 100

#16960. Kate’s 2021 Celebration

统计

Kate 的 2020 年过得并不顺利,她很高兴这一年即将结束。她计划盛大地面向 2021 年新年进行庆祝。

Kate 决定购买四个印有数字 2、0、2、1 的气球用于她的 2021 年庆祝活动。她浏览了一家商店的网站,发现带数字的气球是成包销售的,每包中含有各种大小、颜色以及印有不同数字的气球组合。Kate 并不关心它们的大小、颜色或其他属性。她只关心气球上写着的数字。幸运的是,商店里有所有可用气球包的完整信息。Kate 通过商店的 REST API 获取了这些信息,并提取出了她需要的内容——每包气球的价格以及其中气球上写着的数字。

请帮助 Kate 完成最后一项任务:找出她可以购买的、能够提供她 2021 年庆祝所需四个数字的最便宜的一包气球。

输入格式

输入的第一行包含一个整数 $n$ ($1 \le n \le 1000$) —— 商店中可用的气球包数量。

接下来的 $n$ 行,每行包含一个气球包的描述。每个气球包由一个整数 $p$ ($1 \le p \le 10^5$) —— 该包气球的价格(单位:卢布),以及一个长度在 $1$ 到 $100$ 之间的数字字符串(每个数字在 $0$ 到 $9$ 之间)—— 表示该包中气球上的数字。

输出格式

输出一个整数 —— Kate 可以购买的、能获得 2021 年庆祝所需数字的最便宜的气球包的编号(气球包按输入顺序从 $1$ 开始编号)。

如果有多个价格相同的最便宜气球包,输出其中任意一个的编号。

如果商店中没有可以满足 Kate 2021 年庆祝所需数字的气球包,则输出 $0$。

样例

样例输入 1

4
100 9876543210
200 00112233445566778899
160 012345678924568
150 000000123456789

样例输出 1

3

样例输入 2

5
100 0123456789
120 0022446688
200 00224466883456789
10 0
10 1

样例输出 2

0

说明

在第一个样例中,第 2 包和第 3 包气球包含数字 2、0、2、1,其中第 3 包最便宜。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.