P26879 [AtCoder] Divide by Rating into Two Groups!
普及+
题目描述

Problem Description

$ N $ members of the Paken Club are arranged in a circular formation. They are numbered clockwise from $ 1 $ to $ N $.

Each member has a value called a rating, where the rating of member $ i $ is $ A_i $.

Penguin-kun, the club leader, wants to divide the $ N $ members into two consecutive groups on the circle, such that the sum of the ratings of the members in one group is $ X $ and the sum of the ratings of the members in the other group is $ Y $.

Determine if this is possible.

Input Format

The input is given from the standard input in the following format:

$ N $ $ X $ $ Y $ $ A_1 $ $ A_2 $ $\ldots$ $ A_N $

Output Format

Output Yes if it is possible to divide the $ N $ members into two groups as described in the problem, otherwise output No.

Sample Input and Output

Sample Input #1

5 6 11
3 4 2 3 5

Sample Output #1

Yes

Sample Input #2

4 4 8
1 2 3 4

Sample Output #2

No

Sample Input #3

10 191 376
72 6 62 98 90 61 36 82 9 51

Sample Output #3

Yes

Notes/Hints

Constraints

  • $2 \leq N \leq 2 \times 10^5$
  • $1 \leq X, Y \leq 10^{15}$
  • $1 \leq A_i \leq 10^9$
  • All inputs are integers

Subtasks

  1. ($ 100 $ points) $N \leq 3000$
  2. ($ 200 $ points) No additional constraints

Sample Explanation 1

If members $ 2 $ and $ 3 $ are placed in one group and the remaining members in another group, the sum of the ratings in each group will be $ X = 6 $ and $ Y = 11 $ respectively. This input satisfies all the constraints of the subtasks.

Sample Explanation 2

It is impossible to divide the $ N $ members into two groups as described in the problem. This input satisfies all the constraints of the subtasks.

Sample Explanation 3

This input satisfies all the constraints of the subtasks. Original idea: penguinman

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 6 11 3 4 2 3 5
样例输出
Yes