#DSU0000049. Suy ra tổng cả dãy (Range Sums)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Suy ra tổng cả dãy (Range Sums)
Range Sums
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
An unknown array consists of integers . You are told the sums of contiguous segments. The -th piece of information gives the value of for some .
You are not asked to compute the total sum. Instead, determine whether the given segment-sum information always uniquely determines , regardless of the actual numerical values of the segment sums. In other words, any two arrays satisfying exactly the same reported segment sums must have the same whole-array sum.
Only the segment endpoints are given in the input, since the answer does not depend on the reported values.
Input
The first line contains . Each of the next lines contains .
Output
Print Yes if the total can be determined; otherwise print No.
Subtasks
- Subtask 1 (20 points): , ; ; the segments are distinct; .
- Subtask 2 (30 points): , ; ; the segments are distinct; .
- Subtask 3 (50 points): ; ; the segments are distinct; .
Examples
Input
3 3
1 2
2 3
2 2
Output
Yes
Explanation
Let and . The intervals reveal , , and , making determinable.