問題一覧 > 通常問題

No.145 yukiover

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 101
作問者 : sugim48
お気に入りにしたユーザー ProblemId : 236 / 自分の提出
問題文最終更新日: 2026-06-26 08:30:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 83 (順位表) の他の問題:

Problem Statement

There are $N$ panels lined up on a desk.
Each panel has a lowercase letter written on it.

You rearrange the panels into several rows, forming a string corresponding to each row.
For each row, if its string is lexicographically greater than yuki, you gain $1$ happiness.

What is the maximum happiness you can obtain?

Input

$N$
$S$

The first line contains an integer $N\ (1\le N\le10^5)$, the number of panels.
The second line contains a string $S$ consisting of $N$ lowercase letters.
The $i$-th panel has the $i$-th character of $S$ written on it.

Output

Output the maximum happiness.

Sample

Sample 1
Input
3
xyz
Output
2

If you form the strings yx and z, both are lexicographically greater than yuki.

Sample 2
Input
4
yuki
Output
0

yuki is lexicographically equal to yuki, so no happiness is gained.

Sample 3
Input
3
zzz
Output
3

You may form any number of identical strings.

Sample 4
Input
11
kyuukyuusya
Output
3

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。