#CCBOTPBA0000046. Kiểm tra số tăng chữ số (Nondecreasing Decimal Digits)
Kiểm tra số tăng chữ số (Nondecreasing Decimal Digits)
Nondecreasing Decimal Digits
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Determine whether the decimal digits of n are nondecreasing from left to right (equal neighboring digits allowed). Zero and single-digit values qualify.
Input
One integer n.
Output
Print YES or NO.
Subtasks
-
Subtask 1 (20%):
n ≤ 999. -
Subtask 2 (30%):
n ≤ 10^9. -
Subtask 3 (50%):
n ≤ 10^18.
Examples
Example 1
Input:
11249
Output:
YES
Explanation: Equal neighboring digits are allowed.
Example 2
Input:
132
Output:
NO
Explanation: The pair 3 then 2 decreases.
Example 3
Input:
0
Output:
YES
Explanation: Zero has only one digit.