PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000131. Ba đoạn liên tiếp có tổng định trước (Iroha and Haiku (New ABC Edition))
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ba đoạn liên tiếp có tổng định trước (Iroha and Haiku (New ABC Edition))
Iroha and Haiku (New ABC Edition)
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers and targets , determine whether there exist four integers such that three nonempty consecutive segments ; ; have sums exactly respectively. The chosen segments need not cover the full array.
Input
The first line contains . The next line contains integers .
Output
Print Yes if suitable indices exist; otherwise print No.
Subtasks
- Subtask 1 (20 points): ; , .
- Subtask 2 (30 points): ; , .
- Subtask 3 (50 points): ; , .
Examples
Input
10 5 7 5
1 3 2 2 2 3 1 4 3 2
Output
Yes
Explanation
Choose zero-based . The three consecutive sums are , , and . Since , print Yes.