#K59417. Exact Distinct Character Removal
Exact Distinct Character Removal
Exact Distinct Character Removal
Given a string s and two integers k and n, determine whether it is possible to remove exactly k characters from s such that the resulting string contains exactly n distinct characters.
This problem can be formulated mathematically as follows: Let \( s \) be a string with length \( |s| \) and let \( d \) be the number of distinct characters in \( s \). We need to verify whether the following conditions can be simultaneously satisfied:
[ \begin{cases} n \le d \ |s| - k \ge n \end{cases} ]
If both conditions hold, output YES; otherwise, output NO.
inputFormat
The input is provided via stdin and consists of three lines:
- The first line contains a string s.
- The second line contains an integer k, the number of characters to remove.
- The third line contains an integer n, the required number of distinct characters after removal.
outputFormat
The output is a single line printed to stdout: print YES if it is possible to remove exactly k characters from s so that the remaining string contains exactly n distinct characters; otherwise, print NO.
## sampleabcabcabc
2
2
YES