CF1060A.Phone Numbers

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.

For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.

You have nn cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct.

我们称一个字符串为“电话号码”,当且仅当它的长度为 11,且符合模式 "8xxxxxxxxxx",其中每个 "x" 均被一个数字替换。

例如,"80123456789" 和 "80000000000" 是电话号码,而 "8012345678" 和 "79000000000" 不是。

你有 nn 张写有数字的卡片,希望用它们尽可能多地组成电话号码。每张卡片至多在一个电话号码中使用,且你不必使用全部卡片。所组成的电话号码彼此之间不要求互不相同。

输入格式

The first line contains an integer nn — the number of cards with digits that you have (1≤n≤1001 \leq n \leq 100).

The second line contains a string of nn digits (characters "0", "1", ..., "9") s1,s2,…,sns_1, s_2, \ldots, s_n. The string will not contain any other characters, such as leading or trailing spaces.

第一行包含一个整数 nn —— 你拥有的数字卡片的数量(1≤n≤1001 \leq n \leq 100)。

第二行包含一个长度为 nn 的数字字符串(字符为 "0"、"1"、…、"9"),记为 s1,s2,…,sns_1, s_2, \ldots, s_n。该字符串不包含任何其他字符,例如首尾空格。

输出格式

If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.

如果可以使用这些卡片至少组成一个电话号码,则输出最多能组成的电话号码数量;否则,输出 0。

输入输出样例

  • 输入#1

    11
    00000000008

    输出#1

    1
  • 输入#2

    22
    0011223344556677889988

    输出#2

    2
  • 输入#3

    11
    31415926535

    输出#3

    0

说明/提示

In the first example, one phone number, "8000000000", can be made from these cards.

In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".

In the third example you can't make any phone number from the given cards.

在第一个例子中,可以使用这些卡片组成一个电话号码:“8000000000”。

在第二个例子中,可以使用这些卡片组成两个电话号码,例如:“80123456789”和“80123456789”。

在第三个例子中,无法使用给定的卡片组成任何电话号码。

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

首页