103256: [Atcoder]ABC325 G - offence

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

Description

Score : $575$ points

Problem Statement

You are given a string $S$. Find the minimum length of a string that can be obtained by performing the following operation on the string $S$ zero or more times.

  • Choose a contiguous occurrence of of in the string and an integer $i$ between $0$ and $K$, inclusive. Then, remove the of and the following $i$ characters from the string.

Constraints

  • $0 \leq K < |S| \leq 300$
  • $K$ is an integer.
  • $S$ is a string consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

$S$
$K$

Output

Print the answer.


Sample Input 1

keyofscience
3

Sample Output 1

7

By choosing the of formed by the fourth and fifth characters and setting $i = 3$, you can remove ofsci from keyofscience and get keyence.
It is impossible to reduce the length of the string to $6$ or less by repeating the operation, so the answer is $7$.


Sample Input 2

oofsifffence
3

Sample Output 2

2

Sample Input 3

ooofff
5

Sample Output 3

0

Sample Input 4

okeyencef
4

Sample Output 4

9

Input

Output

得分:575分 部分 问题描述 给你一个字符串S。找出可以通过对字符串S进行以下操作0次或多次得到的最短字符串的长度。 选择字符串中连续出现的"of",以及一个介于0和K(含)之间的整数i。然后从字符串中删除"of"和其后的i个字符。 部分 约束条件 $0 \leq K < |S| \leq 300$ K是一个整数。 S是一个由小写英文字母组成的字符串。 部分 输入 输入通过标准输入以以下格式给出: $S$ $K$ 部分 输出 打印答案。 部分 样例输入1 keyofscience 3 部分 样例输出1 7 你可以通过选择由第4个和第5个字符形成的"of"并设置i=3,从keyofscience中删除ofsci,得到keyence。 通过重复操作将字符串的长度缩短到6或以下是不可能的,所以答案是7。 部分 样例输入2 oofsifffence 3 部分 样例输出2 2 部分 样例输入3 ooofff 5 部分 样例输出3 0 部分 样例输入4 okeyencef 4 部分 样例输出4 9

加入题单

算法标签: