305690: CF1076A. Minimizing the String
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Minimizing the String
题意翻译
# 题目大意 给你一个长为 $n$ 的字符串 要求 **删去一个字符或不删**,使得字符串的**字典序尽可能小** **注 :** 字符串字典序的比较优先级为 1. 从左往右第一个不同字符的 ASCII 值的大小关系 2. 字符串长度 # 输入输出 ## 输入 第一行输入一个整数 $n$ ,为字符串长度, 第二行输入长为 $n$ 的字符串。 ## 输出 输出仅一行 —— 修改后的字符串 $s$ ~~来自英语不及格的人 @十分地弱鸡 的翻译~~题目描述
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 = s_1 s_2 \dots s_n $ is lexicographically smaller than string $ t = t_1 t_2 \dots t_m $ if $ n < m $ and $ s_1 = t_1, s_2 = t_2, \dots, s_n = t_n $ or there exists a number $ p $ such that $ p \le n $ and $ s_1 = t_1, s_2 = t_2, \dots, s_{p-1} = t_{p-1} $ and $ s_p < t_p $ . 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 \le n \le 2 \cdot 10^5 $ ) — 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