-
Notifications
You must be signed in to change notification settings - Fork 0
/
19539.cpp
88 lines (76 loc) · 1.35 KB
/
19539.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
cin >> N;
vector<int> vec;
int a;
long long one = 0;
long long two = 0;
for (int i = 0; i < N; ++i) {
cin >> a;
if (a == 1) {
++one;
}
else if (a == 2) {
++two;
}
vec.push_back(a);
}
for (int i = 0; i < N; ++i) {
if (vec[i] > 2) {
if (vec[i] >= 6 && vec[i] % 6 == 0) {
two += (vec[i] / 6) * 3;
}
else if (vec[i] >= 6 && vec[i] % 6 == 1) {
one += 1;
two += (vec[i] / 6) * 3;
}
else if (vec[i] >= 6 && vec[i] % 6 == 2) {
two += ((vec[i] / 6) * 3) + 1;
}
else if (vec[i] >= 6 && vec[i] % 6 == 3) {
two += ((vec[i] / 6) * 3) + 1;
++one;
}
else if (vec[i] >= 6 && vec[i] % 6 == 4) {
two += ((vec[i] / 6) * 3) + 2;
}
else if (vec[i] >= 6 && vec[i] % 6 == 5) {
two += ((vec[i] / 6) * 3) + 2;
++one;
}
else if (vec[i] % 3 == 0) {
one += vec[i] / 3;
two += vec[i] / 3;
}
else if (vec[i] % 3 == 1) {
two += (vec[i] / 3) + 1;
}
else if (vec[i] % 3 == 2) {
one += vec[i] / 3;
two += (vec[i] / 3) + 1;
}
}
}
bool isItYes = false;
while (one < two) {
--two;
++one;
++one;
}
if (one == two) {
isItYes = true;
}
if (isItYes) {
cout << "YES";
}
else {
cout << "NO";
}
return 0;
}