-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1933B.cpp
More file actions
48 lines (38 loc) · 678 Bytes
/
Copy path1933B.cpp
File metadata and controls
48 lines (38 loc) · 678 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
45
46
47
48
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main () {
ll t, inp;
cin >> t;
while (t--) {
ll n, tot = 0;
cin >> n;
vector <ll> v;
for (ll i = 0; i < n; i++) {
cin >> inp;
if (inp % 3 != 0) {
v.pb(inp);
tot += inp;
}
}
if (tot % 3 == 0) {
cout << 0 << endl;
} else {
ll toIncrease = 3 - (tot % 3);
//Can be 1 or 2
ll cnt = 0;
for (auto it : v) {
if (tot % 3 == it % 3) {
cnt++;
break;
}
}
if (cnt == 1) {
cout << cnt << endl;
} else {
cout << toIncrease << endl;
}
}
}
}