QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB Puntuación total: 100

#3795. 彩票欢乐时光

Estadísticas

彩票最大的乐趣不在于获得(通常是微不足道的)奖金,而在于梦想你可能(实际上几乎不可能)获得的巨额财富。

你手头有一些彩票,每张彩票上都有一个六位数字。当然,所有数字各不相同。明天是开奖日,奖项设置如下:

  • 一等奖:奖金 300,000 日元,由六位数字与一等奖中奖号码完全相同的彩票获得。
  • 二等奖:奖金 4,000 日元,由末四位数字与二等奖中奖号码相同的彩票获得。
  • 三等奖:奖金 500 日元,由末两位数字与三个三等奖中奖号码中的任意一个相同的彩票获得。

彩票上的六位数字和所有中奖号码都可能以零开头。

所有中奖号码的末两位数字各不相同,因此获得三等奖的彩票不可能同时获得一等奖或二等奖。注意,这一规则也使得一等奖和二等奖中奖号码的末两位数字各不相同。

为了享受彩票开奖的乐趣,你决定计算一下你手中的彩票可能获得的最大奖金总额。你手中的彩票太多,无法手工计算,但编写一个程序来完成这项计算应该也是一种乐趣。

输入格式

输入的第一行包含一个正整数 $n$ ($n \le 10^5$),表示你手中彩票的数量。接下来的 $n$ 行,每行包含一张彩票上的六位数字。这 $n$ 个数字互不相同。

输出格式

输出一行一个整数,表示你手中彩票可能获得的最大奖金总额。

样例

样例输入 1

7
034207
924837
372745
382947
274637
083907
294837

样例输出 1

309500

样例输入 2

10
012389
456789
234589
678989
890189
567889
123489
263784
901289
345689

样例输出 2

304500

说明

对于第一个样例,以下中奖号码组合可以获得 309500 日元的最大奖金总额:

  • 一等奖中奖号码 382947 使得一张号码为 382947 的彩票获得 300000 日元。
  • 二等奖中奖号码 4837 使得两张彩票 924837 和 294837 各获得 4000 日元。
  • 三等奖中奖号码 07 和 45 使得三张彩票 034207、083907 和 372745 各获得 500 日元。37 不能作为三等奖中奖号码,因为二等奖中奖号码 4837 的末两位数字为 37。因此,彩票 274637 没有中奖。无论剩下的那个三等奖中奖号码是什么,你都没有更多的彩票可以中奖了。

对于第二个样例,十张彩票中有九张的末两位数字相同,均为 89,因此三等奖中奖号码 89 可以带来九个三等奖,总计 4500 日元。这比这九张彩票中可能有一张获得二等奖的 4000 日元奖金要多。剩下的唯一一张彩票 263784 当然应该获得一等奖。

Figure 1. 彩票梦想

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.