#GD0000198. Xóa chữ số để giành giải thưởng (Erasing and Winning)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Xóa chữ số để giành giải thưởng (Erasing and Winning)
Erasing and Winning
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
On the television show Erasing and Winning, the host writes a positive integer with digits on a board. The contestant must erase exactly digits. The remaining digits, in their original relative order, form the prize amount.
Digits cannot be rearranged, changed, or added. The original number has no leading zero, although zeroes may appear elsewhere.
Find the largest number obtainable after exactly deletions. Since the result may contain many digits, print its decimal representation directly. Exactly digits remain.
Input
- The first line contains integers and : the initial number of digits and the exact number of digits to erase.
- The second line contains exactly decimal digits, with its first digit different from
0.
Output
Print one line containing exactly digits: the largest number obtainable after deleting exactly digits while preserving order.
Subtasks
- Subtask 1 (20 points): ; ; The digit string has length and does not begin with
0. - Subtask 2 (30 points): ; ; The digit string has length and does not begin with
0. - Subtask 3 (50 points): ; ; The digit string has length and does not begin with
0.
Examples
Input
4 2
3759
Output
79
Explanation
There are four digits 3, 7, 5, 9, and exactly two must be deleted. The order-preserving pairs are 37, 35, 39, 75, 79, and 59. The largest is 79, obtained by deleting 3 at position and 5 at position .