S003-AC.cc
548 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
using namespace std;
bool hasSum(int* array, int n)
{
int m = 0;
while(m != n)
{
if(array[m] == array[n] - array[m++])
{
return true;
}
}
return false;
}
int main()
{
int n, m;
while(cin >> n)
{
int* array = new int[n+1];
m = 0;
for(int i = 0; i < n+1; i++)
{
array[i] = 0;
}
while(m != n)
{
cin >> array[m++];
array[n] += array[m-1];
}
if(hasSum(array,n))
{
cout << "YES" << endl;
delete[] array;
continue;
}
cout << "NO" << endl;
delete[] array;
}
return 0;
}