#D11162. Range Minimum Query
Range Minimum Query
Range Minimum Query
Problem statement
There are real variables , and some initial value is assigned. From now on, pieces of information will be given in order. The information given is one of the following two types.
- min $ \\ {X_ {a_i}, X_ {a_i + 1}, ..., X_ {b_i} \\} = y_i $.
- Substitute for the variables .
Determine if you can choose the initial value of each variable so that these pieces of information are consistent.
Constraint
input
Input follows the following format. All given numbers are integers.
- When , it indicates that min $ \\ {X_ {a_i}, X_ {a_i + 1}, ..., X_ {b_i} \\} = y_i $.
- When , it indicates that is assigned to .
output
Output "YES" if there is an initial value that does not contradict all the information, otherwise output "NO" on one line.
Examples
Input
5 0 1 2 8 0 2 3 9 0 2 2 11 1 2 2 7 0 1 3 7
Output
YES
Input
2 1 10 100 333 0 100 1000 555
Output
NO
inputFormat
input
Input follows the following format. All given numbers are integers.
- When , it indicates that min $ \\ {X_ {a_i}, X_ {a_i + 1}, ..., X_ {b_i} \\} = y_i $.
- When , it indicates that is assigned to .
outputFormat
output
Output "YES" if there is an initial value that does not contradict all the information, otherwise output "NO" on one line.
Examples
Input
5 0 1 2 8 0 2 3 9 0 2 2 11 1 2 2 7 0 1 3 7
Output
YES
Input
2 1 10 100 333 0 100 1000 555
Output
NO
样例
2
1 10 100 333
0 100 1000 555
NO