Codeforces Round 124 (Div. 1)
A
Lexicographically Maximum Subsequence
Codeforces
1100
原题
←B →
翻译中…

You've got string $*s*$, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.

翻译中…

We'll call a non-empty string $*s*[*p*_{1}*p*_{2}... *p*_{*k*}] = *s*_{*p*_{1}}*s*_{*p*_{2}}... *s*_{*p*_{*k*}}(1 ≤ *p*_{1} < *p*_{2} < ... < *p*_{*k*} ≤ |*s*|)$ a subsequence of string $*s* = *s*_{1}*s*_{2}... *s*_{|*s*|}$.

翻译中…

String $*x* = *x*_{1}*x*_{2}... *x*_{|*x*|}$ is lexicographically larger than string $*y* = *y*_{1}*y*_{2}... *y*_{|*y*|}$, if either $|*x*| > |*y*|$ and $*x*_{1} = *y*_{1}, *x*_{2} = *y*_{2}, ... , *x*_{|*y*|} = *y*_{|*y*|}$, or exists such number $*r*$ $(*r* < |*x*|, *r* < |*y*|)$, that $*x*_{1} = *y*_{1}, *x*_{2} = *y*_{2}, ... , *x*_{*r*} = *y*_{*r*}$ and $*x*_{*r* + 1} > *y*_{*r* + 1}$. Characters in lines are compared like their ASCII codes.

翻译中…

Input

翻译中…

The single line contains a non-empty string $*s*$, consisting only of lowercase English letters. The string's length doesn't exceed $10^{5}$.

翻译中…

Output

翻译中…

Print the lexicographically maximum subsequence of string $*s*$.

翻译中…

Note

翻译中…

Let's look at samples and see what the sought subsequences look like (they are marked with uppercase bold letters).

翻译中…

The first sample: aBaBBA

翻译中…

The second sample: abbCbCCaCbbCBaaBA

翻译中…

样例

Input #1
ababba
Output #1
bbba
InputCopy OutputCopy
Input #2
abbcbccacbbcbaaba
Output #2
cccccbba
InputCopy OutputCopy
题目信息
题号
196A
时间限制
2 s
内存限制
256 MB
标签
贪心
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。