CF999C.Alphabetic Removals

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string ss consisting of nn lowercase Latin letters. Polycarp wants to remove exactly kk characters (k≤nk \le n) from the string ss. Polycarp uses the following algorithm kk times:

  • if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
  • if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
  • ...
  • remove the leftmost occurrence of the letter 'z' and stop the algorithm.

This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly kk times, thus removing exactly kk characters.

Help Polycarp find the resulting string.

给你一个由 nn 个小写拉丁字母组成的字符串 ss。Polycarp 想要从字符串 ss 中恰好移除 kk 个字符(其中 k≤nk \le n)。Polycarp 使用如下算法,共执行 kk 次:

  • 如果字符串中至少存在一个字母 'a',则移除最左侧的 'a' 并终止本次算法;否则进入下一项;
  • 如果字符串中至少存在一个字母 'b',则移除最左侧的 'b' 并终止本次算法;否则进入下一项;
  • ...
  • 移除最左侧的字母 'z' 并终止本次算法。

该算法每次仅从字符串中移除一个字母。Polycarp 恰好执行该算法 kk 次,因此总共移除 kk 个字符。

请帮助 Polycarp 找出最终得到的字符串。

输入格式

The first line of input contains two integers nn and kk (1≤k≤n≤4⋅1051 \le k \le n \le 4 \cdot 10^5) — the length of the string and the number of letters Polycarp will remove.

The second line contains the string ss consisting of nn lowercase Latin letters.

输入的第一行包含两个整数 nn 和 kk(1≤k≤n≤4⋅1051 \le k \le n \le 4 \cdot 10^5)—— 分别表示字符串的长度以及 Polycarp 将要删除的字母个数。

第二行包含一个由 nn 个小写拉丁字母组成的字符串 ss。

输出格式

Print the string that will be obtained from ss after Polycarp removes exactly kk letters using the above algorithm kk times.

If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).

按照上述算法,将字符串 ss 经过 Polycarp 恰好 kk 次删除操作后得到的字符串输出。

如果最终得到的字符串为空,则不输出任何内容。允许不输出任何内容或仅输出一个空行(换行符)。

输入输出样例

  • 输入#1

    15 3
    cccaabababaccbc

    输出#1

    cccbbabaccbc
  • 输入#2

    15 9
    cccaabababaccbc

    输出#2

    cccccc
  • 输入#3

    1 1
    u

    输出#3

输入解题思路,AI测评打分。不知道怎么写?

首页