Posted on 2008-03-29 15:19
superman 阅读(378)
评论(1) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1028 C++ 00:00.00 832K */
2 #include <stdlib.h>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 int n;
10 bool track[50];
11
12 cin >> n;
13 while(cin >> n)
14 {
15 int blackOnOdd = 0, blackOnEven = 0;
16 for(int i = 1; i <= n; i++)
17 {
18 cin >> track[i];
19 if(i % 2)
20 blackOnOdd += track[i];
21 else
22 blackOnEven += track[i];
23 }
24
25 if(n % 2)
26 cout << "YES" << endl;
27 else
28 {
29 if(abs(blackOnOdd - blackOnEven) <= 1)
30 cout << "YES" << endl;
31 else
32 cout << "NO" << endl;
33 }
34 }
35
36 return 0;
37 }
38