-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path107A. Review Site.cpp
58 lines (54 loc) · 1.17 KB
/
107A. Review Site.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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define all(v) v.begin(),v.end()
#define loop(i, n) for (ll (i) = 0; (i)<(n); (i)++)
#define test int t; cin>> t; while(t--)
const int N = 1e6 + 7;
int mod = 1e9;
int arr[N];
int arr2[101][101];
void init() {
cin.tie(0);
cin.sync_with_stdio(0);
}
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
int main() {
init();
int n,x;
test{
map<int,int>mp1,mp2;
cin>>n;
loop(i,n){
cin>>x;
if(x == 1){
if(mp1[1]>mp1[2])
mp2[1]++;
else mp1[1]++;
}
else if(x == 2){
if(mp1[2]<mp1[1])
mp1[2]++;
else mp2[2]++;
}
else{
if(mp1[1]>= mp1[2])mp1[1]++;
else if(mp2[1]>= mp2[2])mp2[1]++;
else {
if(mp1[2]<mp1[1])mp1[2]++;
else mp2[2]++;
}
}
}
cout<<mp1[1]+mp2[1]<<"\n";
};
return 0;
}