-
Notifications
You must be signed in to change notification settings - Fork 0
/
CupBoards.cpp
74 lines (54 loc) · 1.04 KB
/
CupBoards.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
#include<bits/stdc++.h>
#define TestCase int t; cin>>t; while(t--)
#define N int n;cin>n;
using namespace std;
int main(){
int n;
cin>>n;
vector<pair<int,int> > v;
for(int i=0;i<n;i++){
int li,ri;
cin>>li>>ri;
v.push_back(make_pair(li,ri));
}
int count0 = 0;
int count1 =0;
for(auto x:v){
if(x.first==0){
count0++;
}
if(x.first==1){
count1++;
}
}
int count02 = 0;
int count01 =0;
for(auto x:v){
if(x.second==0){
count02++;
}
if(x.second==1){
count01++;
}
}
int need1 =0;
int need2 =0;
if(count0>count1){
need1 = 0;
}else{
need1 = 1;
}
if(count02>count01){
need2 =0;
}else need2 = 1;
int t =0;
for(auto x:v){
if(x.first!=need1){
t++;
}
if(x.second!=need2){
t++;
}
}
cout<<t<<" ";
}