Kindness
Limits: 2 sec., 256 MiB
"Today is a very good day" — thought Zenyk and decided to give out candies to all children. Zenyk has \(N\) boxes with candies, \(i\)-th box contains \(A_i\) candies, all boxes are placed in a row.
Zenyk met \(K\) children. Every child get some continuous subarray of boxes. More formally Zenyk chooses 2 integers \(L\), \(R\) and presents \(A_L+A_{L+1}+\dots+A_R\) candies. After that \(L-1\)-th and \(R+1\)-th boxes become neighboring.
You should find if Zenyk can giveaway all boxes such that every child get the same amount of candies.
Input
First line contains 2 integers \(N\) and \(K\).
Second line contains \(N\) integers \(A_i\).
Output
Print "YES"
if Zenyk can giveaway all candies and
"NO"
otherwise.
Constraints
\(1 \le N \le 500\),
\(1 \le K \le N\),
\(1 \le A_i \le 10^9\).
Samples
Input (stdin) | Output (stdout) |
---|---|
4 2 2 3 4 5 | YES |
Input (stdin) | Output (stdout) |
---|---|
4 2 2 3 5 4 | NO |
Notes
In the first sample Zenyk gives 2-nd and 3-rd boxes to the first child. Then remaining 2 boxes (2,5) to the second child. Both children get 7 candies.
Submit a solution
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|