#CCBCHBAHAI0000065. Kiểm tra mảng không giảm (Check a Nondecreasing Array)
Kiểm tra mảng không giảm (Check a Nondecreasing Array)
Check a Nondecreasing Array (Kiểm tra mảng không giảm)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given , the array is nondecreasing if
Equal adjacent values are allowed. Determine whether the array satisfies this condition without sorting it.
Input
The first line contains . The second line contains integers .
Output
Print YES if the array is nondecreasing; otherwise print NO.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
6
-3 -3 0 4 4 10
Output
YES
Explanation
The sample follows the mathematical definition above.