310958: CF1914A. Problemsolving Log

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Problemsolving Logtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Monocarp is participating in a programming contest, which features $26$ problems, named from 'A' to 'Z'. The problems are sorted by difficulty. Moreover, it's known that Monocarp can solve problem 'A' in $1$ minute, problem 'B' in $2$ minutes, ..., problem 'Z' in $26$ minutes.

After the contest, you discovered his contest log — a string, consisting of uppercase Latin letters, such that the $i$-th letter tells which problem Monocarp was solving during the $i$-th minute of the contest. If Monocarp had spent enough time in total on a problem to solve it, he solved it. Note that Monocarp could have been thinking about a problem after solving it.

Given Monocarp's contest log, calculate the number of problems he solved during the contest.

Input

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of testcases.

The first line of each testcase contains a single integer $n$ ($1 \le n \le 500$) — the duration of the contest, in minutes.

The second line contains a string of length exactly $n$, consisting only of uppercase Latin letters, — Monocarp's contest log.

Output

For each testcase, print a single integer — the number of problems Monocarp solved during the contest.

ExampleInput
3
6
ACBCBC
7
AAAAFPC
22
FEADBBDFFEDFFFDHHHADCC
Output
3
1
4

Output

题目大意:
Monocarp 参加了一个编程比赛,比赛有26个按照难度排序的问题,分别命名为'A'到'Z'。Monocarp 解决问题'A'需要1分钟,问题'B'需要2分钟,以此类推,直到问题'Z'需要26分钟。比赛结束后,你发现了他的比赛日志,这是一个由大写拉丁字母组成的字符串,第i个字母表示 Monocarp 在比赛的第i分钟正在解决的问题。如果 Monocarp 在一个问题上的总耗时足以解决它,那么他就解决了这个问题。注意,Monocarp 在解决问题后可能还在思考它。

给定 Monocarp 的比赛日志,计算他在比赛中解决了多少个问题。

输入输出数据格式:
输入:
- 第一行包含一个整数t(1 ≤ t ≤ 100),表示测试用例的数量。
- 每个测试用例的第一行包含一个整数n(1 ≤ n ≤ 500),表示比赛的持续时间,以分钟计。
- 第二行包含一个长度为n的字符串,由大写拉丁字母组成,表示 Monocarp 的比赛日志。

输出:
- 对于每个测试用例,打印一个整数,表示 Monocarp 在比赛中解决的问题数量。

示例:
输入:
```
3
6
ACBCBC
7
AAAAFPC
22
FEADBBDFFEDFFFDHHHADCC
```
输出:
```
3
1
4
```题目大意: Monocarp 参加了一个编程比赛,比赛有26个按照难度排序的问题,分别命名为'A'到'Z'。Monocarp 解决问题'A'需要1分钟,问题'B'需要2分钟,以此类推,直到问题'Z'需要26分钟。比赛结束后,你发现了他的比赛日志,这是一个由大写拉丁字母组成的字符串,第i个字母表示 Monocarp 在比赛的第i分钟正在解决的问题。如果 Monocarp 在一个问题上的总耗时足以解决它,那么他就解决了这个问题。注意,Monocarp 在解决问题后可能还在思考它。 给定 Monocarp 的比赛日志,计算他在比赛中解决了多少个问题。 输入输出数据格式: 输入: - 第一行包含一个整数t(1 ≤ t ≤ 100),表示测试用例的数量。 - 每个测试用例的第一行包含一个整数n(1 ≤ n ≤ 500),表示比赛的持续时间,以分钟计。 - 第二行包含一个长度为n的字符串,由大写拉丁字母组成,表示 Monocarp 的比赛日志。 输出: - 对于每个测试用例,打印一个整数,表示 Monocarp 在比赛中解决的问题数量。 示例: 输入: ``` 3 6 ACBCBC 7 AAAAFPC 22 FEADBBDFFEDFFFDHHHADCC ``` 输出: ``` 3 1 4 ```

加入题单

上一题 下一题 算法标签: