問題一覧 > 通常問題

No.1943 The Vanishing AGCT (1)

レベル : / AI推定難易度 : 500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 206
作問者 : H20 / テスター : 蜜蜂 naskya
お気に入りにしたユーザー ProblemId : 7916 / 自分の提出
問題文最終更新日: 2022-05-05 15:27:07
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 344 (順位表) の他の問題:

Problem Statement

A string $s$ of $n$ characters consisting only of uppercase English letters is given as input.

You perform operations so that $s$ satisfies the condition. Output the minimum number of operations required.

Condition: $s$ does not contain any of the characters A,G,C,T

One operation consists of carrying out the following steps 1. through 3. in order. The steps cannot be reordered, and no step can be skipped.

Operation:

  1. Let $c$ be the total number of characters A,G,C,T contained in $s$
  2. Let $t$ be the string obtained by deleting the $c$-th character of $s$
  3. Replace $s$ with $t$

Input

$n$
$s$

Constraints

  • $ 1 \le n \le 5 \times 10^{5}$
  • $|s|=n$
  • $s$ consists only of uppercase English letters
  • $n$ is an integer

Output

Output the minimum number of operations required until the condition is satisfied.

Print a newline at the end.

Sample

Sample 1
Input
6
ABCDEF
Output
3

The string changes as ABCDEF→ACDEF→ADEF→DEF.

Sample 2
Input
9
YUKICODER
Output
5

Sample 3
Input
19
ATCODERGRANDCONTEST
Output
19

Sample 4
Input
3
XYZ
Output
0

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