#K62322. Lexicographically Smallest String After Fixed Deletions

    ID: 31506 Type: Default 1000ms 256MiB

Lexicographically Smallest String After Fixed Deletions

Lexicographically Smallest String After Fixed Deletions

You are given an integer \(d\) and a string \(S\). Your task is to delete exactly \(d\) characters from \(S\) such that the resulting string is the lexicographically smallest possible. This problem requires a greedy approach to find the optimal sequence of characters that remains.

For example, if \(d = 2\) and \(S = \texttt{abcde}\), by removing two characters you can obtain \(\texttt{abc}\), which is the smallest possible string in lexicographic order.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains an integer \(d\) — the number of characters to delete.
  • The second line contains the string \(S\) from which characters are to be removed.

outputFormat

Output the lexicographically smallest string that can be obtained by deleting exactly \(d\) characters from \(S\). The output should be printed to standard output (stdout).

## sample
2
abcde
abc