AtCoder Regular Contest 191 (Div. 2)
翻译中…
Problem Statement
翻译中…
You are given a string $S$ of length $N$ and a string $T$ of length $M$, both consisting of digits from 1 to 9.
翻译中…
You will perform the following operation for $k=1,2,\ldots,M$ in order:
翻译中…
- Choose an integer
$i$such that$1 \le i \le N$. Then, replace the$i$-th character of$S$with the$k$-th character of$T$.
翻译中…
Find the maximum possible value of the resulting string $S$ interpreted as an integer after performing the $M$ operations.
翻译中…
Constraints
翻译中…
$1 \le N,M \le 10^6$$N$and$M$are integers.$S$is a string of length$N$consisting of digits from1through9.$T$is a string of length$M$consisting of digits from1through9.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N M
S
T
翻译中…
Output
翻译中…
Print the maximum possible value of the resulting string $S$ interpreted as an integer after performing the $M$ operations.
翻译中…
样例
Input #1
3 3
191
325
Output #1
593
The following sequence of operations is optimal:
- For $k=1$: Choose $i=3$. Then, $S =$ `193`.
- For $k=2$: Choose $i=1$. Then, $S =$ `293`.
- For $k=3$: Choose $i=1$. Then, $S =$ `593`.
In this case, the value of $S$ interpreted as an integer is $593$, which is the maximum.
Input #2
3 9
191
998244353
Output #2
993
Input #3
11 13
31415926535
2718281828459
Output #3
98888976555
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。