-
Notifications
You must be signed in to change notification settings - Fork 0
/
EGYPIZZA.cpp
54 lines (49 loc) · 902 Bytes
/
EGYPIZZA.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
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
int count(int arr[],int n,int val)
{
int sum=0;
for(int i=0;i<n;i++)
sum+=arr[i]/val;
return sum;
}
int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
lld arr[3]={0};
string s;
while(t--)
{
cin>>s;
if(s[0]=='1'&&s[2]=='2')
arr[0]++;
else if(s[0]=='1')
arr[1]++;
else
arr[2]++;
}
lld res=0;
if(arr[1]>=arr[2])
{
res+=arr[2];
arr[1]-=arr[2];
arr[2]=0;
lld sum=2*arr[0]+arr[1];
if(sum%4!=0)
res++;
res+=sum/4;
}
else
{
res+=arr[2];
if(arr[0]%2!=0)
res++;
res+=arr[0]/2;
}
res++;
cout<<res;
}