CF2206K.Time Display Stickers
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have a collection of n digit stickers, represented by a string S of length n. Each character of S is a digit 0 through 9, representing one sticker of that digit.
You want to create time displays using these stickers. Each time display shows a time in the format HH:MM, where:
- HH is a two-digit hour between 00 and 11 (inclusive), and
- MM is a two-digit minute between 00 and 59 (inclusive).
In other words, each time display requires exactly four stickers: two for the hours and two for the minutes. Each sticker can only be used for at most one time display.
What is the maximum number of time displays you can create?
你有一组 n 个数字贴纸,用一个长度为 n 的字符串 S 表示。S 的每个字符都是一个数字(0 到 9),代表一个对应数字的贴纸。
你想使用这些贴纸来制作时间显示。每个时间显示以格式 HH:MM 呈现,其中:
- HH 是一个两位数的小时,取值范围为 00 到 11(含端点);
- MM 是一个两位数的分钟,取值范围为 00 到 59(含端点)。
换句话说,每个时间显示恰好需要四张贴纸:两张用于小时,两张用于分钟。每张贴纸最多只能在一个时间显示中使用。
你最多能制作多少个时间显示?
输入格式
The first line of input contains one integer t (1≤t≤10000) representing the number of test cases. After that, t test cases follow. Each of them is presented as follows.
The first line of each test case contains an integer n (1≤n≤106).
The second line contains a string S of length n, consisting only of digits 0–9.
The sum of n across all test cases in one input file does not exceed 106.
输入的第一行包含一个整数 t(1≤t≤10000),表示测试用例的数量。随后是 t 个测试用例,每个测试用例的格式如下:
每个测试用例的第一行包含一个整数 n(1≤n≤106)。
第二行包含一个长度为 n 的字符串 S,仅由数字 0–9 组成。
在单个输入文件中,所有测试用例的 n 值之和不超过 106。
输出格式
For each test case, output the maximum number of time displays you can create.
对于每个测试用例,输出你能创建的时间显示的最大数量。
输入输出样例
输入#1
4 10 0123456789 11 00123456789 8 99111111 4 1234
输出#1
1 2 2 0
说明/提示
Explanation for the sample input/output #1
For the first test case, you can create one time display 10:59. It can be shown that you cannot create two displays for a given collection of stickers.
For the second test case, you can create two time displays: 10:59 and 04:27.
For the third test case, you can create two time displays: 11:19 and 11:19.
For the fourth test case, you cannot create any time displays.
样例输入/输出 #1 的解释
对于第一个测试用例,你可以制作一个时间显示:10:59。可以证明,对于给定的贴纸集合,你无法制作两个时间显示。
对于第二个测试用例,你可以制作两个时间显示:10:59 和 04:27。
对于第三个测试用例,你可以制作两个时间显示:11:19 和 11:19。
对于第四个测试用例,你无法制作任何时间显示。
输入解题思路,AI测评打分。不知道怎么写?