-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegypizza.cpp
56 lines (55 loc) · 1.11 KB
/
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
55
56
#include<iostream>
#include<string>
using namespace std;
int main(){
int n,one,two,three,i,num,den;
string input;
cin>>n;
one=0;
two=0;
three=0;
for(i=0;i<n;i++){
cin>>input;
num=input[0]-'0';
den=input[2]-'0';
if(num==1 && den==4)
one++;
else if(num==1 && den==2)
two++;
else
three++;
}
int sum=0;
if(three>=one){
sum = sum + three + (two/2);
if(two%2)
sum = sum + 1;
}
else{
sum = sum + three + (two/2);
one = one - three;
if(two%2){
two=1;
if(one>=2){
one = one - 2;
two--;
sum++;
if(one>0){
sum = sum + one/4;
if(one%4)
sum++;
}
}
else
sum++;
}
else{
sum = sum + (one/4);
if(one%4)
sum++;
}
}
cout<<sum+1<<endl;
system("pause");
return 0;
}