CF1076A.Minimizing the String
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string s consisting of n lowercase Latin letters.
You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.
String s=s1s2…sn is lexicographically smaller than string t=t1t2…tm if n<m and s1=t1,s2=t2,…,sn=tn or there exists a number p such that p≤n and s1=t1,s2=t2,…,sp−1=tp−1 and sp<tp .
For example, "aaa" is smaller than "aaaa", "abb" is smaller than "abc", "pqr" is smaller than "z".
输入格式
The first line of the input contains one integer n ( 2≤n≤2⋅105 ) — the length of s .
The second line of the input contains exactly n lowercase Latin letters — the string s .
输出格式
Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string s .
输入输出样例
输入#1
3 aaa
输出#1
aa
输入#2
5 abcda
输出#2
abca
说明/提示
In the first example you can remove any character of s to obtain the string "aa".
In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda".