CF169B.Replacing Digits
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1 ≤ j ≤ m) of sequence s means that you can choose an arbitrary position i (1 ≤ i ≤ n) in a and replace the digit in the chosen position i with s__j. Each element in the sequence s can participate in no more than one replacing operation.
Your task is to perform such sequence of replacements, that the given number a gets maximum value. You are allowed to use not all elements from s.
给你一个由 n 位数字组成的整数 a。同时给你一个长度为 m 的数字序列 s。序列 s 中第 j 个位置(1 ≤ j ≤ m)上的数字表示:你可以任选 a 中的一个位置 i(1 ≤ i ≤ n),并将该位置上的数字替换为 sj。序列 s 中的每个元素最多只能参与一次替换操作。
你的任务是执行一系列替换操作,使得给定的数字 a 达到最大值。你不必使用 s 中的所有元素。
输入格式
The first line contains positive integer a. Its length n is positive and doesn't exceed 105. The second line contains sequence of digits s. Its length m is positive and doesn't exceed 105. The digits in the sequence s are written consecutively without any separators.
The given number a doesn't contain leading zeroes.
第一行包含一个正整数 a。其长度 n 为正,且不超过 105。第二行包含一个数字序列 s。其长度 m 为正,且不超过 105。序列 s 中的数字连续书写,中间不加任何分隔符。
给定的数字 a 不含前导零。
输出格式
Print the maximum value that can be obtained from a after a series of replacements. You are allowed to use not all elements from s. The printed number shouldn't contain any leading zeroes.
输出经过一系列替换后,字符串 a 能得到的最大值。允许不使用 s 中的全部元素。输出的数字不能包含前导零。
输入输出样例
输入#1
1024 010
输出#1
1124
输入#2
987 1234567
输出#2
987
输入解题思路,AI测评打分。不知道怎么写?