시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 189 | 64 | 60 | 40.268% |
A number is said to Rise and Fall if the decimal representation can be broken up into two parts (possibly empty) where the first part has digits in nondecreasing order and the second part has digits in nonincreasing order.
Compute the largest number less than or equal to an input number that rises and falls.
The first line of input contains an integer $t$ ($1 \le t \le 10^5$), which is the number of test cases.
Each of the next $t$ lines contains a single integer $n$ ($1 \le n < 10^{100{,}000}$). Each is a single test case.
The sum of the lengths of all input test cases will not exceed $10^5$.
For each test case, output a single line with a single integer, which is the largest number less than or equal to the $n$ for that test case that rises and falls.
2 29041 56577
29000 56555
ICPC > Regionals > North America > Pacific Northwest Regional > 2021 ICPC Pacific Northwest Region > Division 1 F번
ICPC > Regionals > North America > Pacific Northwest Regional > 2021 ICPC Pacific Northwest Region > Division 2 S번
ICPC > Regionals > North America > South Central USA Regional > 2021 South Central USA Regional Contest > Division 2 G번
ICPC > Regionals > North America > Northeast North America Regional > 2021 Northeast North America Regional Contest E번
ICPC > Regionals > North America > Southeast USA Regional > 2021 Southeast USA Regional Programming Contest > Division 2 G번