304237: CF808D. Array Division
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Array Division
题意翻译
给你一组数,问可以最多移动一个数,使得这一串数可以分成两个部分,每一部分所有数的和相等。题目描述
Vasya has an array $ a $ consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part. It is not always possible, so Vasya will move some element before dividing the array (Vasya will erase some element and insert it into an arbitrary position). Inserting an element in the same position he was erased from is also considered moving. Can Vasya divide the array after choosing the right element to move and its new position?输入输出格式
输入格式
The first line contains single integer $ n $ ( $ 1<=n<=100000 $ ) — the size of the array. The second line contains $ n $ integers $ a_{1},a_{2}...\ a_{n} $ ( $ 1<=a_{i}<=10^{9} $ ) — the elements of the array.
输出格式
Print YES if Vasya can divide the array after moving one element. Otherwise print NO.
输入输出样例
输入样例 #1
3
1 3 2
输出样例 #1
YES
输入样例 #2
5
1 2 3 4 5
输出样例 #2
NO
输入样例 #3
5
2 2 3 4 5
输出样例 #3
YES