PDP-22 (2010) - Camp common - 3 (rdigits)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

Digit Deletion

You are given an N-digit natural number and a list of M digits. The list contains only digits from 1 to 9. Each digit in the list must be deleted from the number.

The list may contain the same digit multiple times, meaning it must be deleted from the number multiple times. However, deletion is always feasible: all the digits in the list appear in the number at least as many times as they appear in the list.

Your goal is to end up with the largest possible number after deleting all the digits appearing in the list.

Input File

The input consists of two lines. The first line contains the N-digit natural number. The second line contains the list of M digits, one after the other, without any spaces.

Output File

The output should consist of a single line with a natural number of N - M digits: the largest possible number that can be obtained after deleting the M digits from the original number.

Examples of Input - Output Files:
1st

STDIN (rdigits.in)

23891343798921
22878193199

STDOUT (rdigits.out)

343
2nd

STDIN (rdigits.in)

123456654321
654321

STDOUT (rdigits.out)

654321
Constraints
  • 5 \le N \le  500.
  • 2 \le M \le N - 2.
  • Maximum Execution Time: 1 sec.
  • Maximum Available Memory: 64 MB.

Comments

There are no comments at the moment.