Ah my bad, I did leave 1 part... Thanks for pointing it out... But still getting WA...
Pls just focus on comments and the flow, that should get the mistake I suppose
#include <cstdio>
#include <string>
#include <iostream>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
int main()
{
int t,i=0,j=0,count=0,min_val,k=0;
string s;
scanf("%d",&t);
while(t--)
{
// input taking
cin>>s;
if(s=="1/4")
j++;
else if(s=="3/4")
k++;
else if(s=="1/2")
i++;
}
while(i!=0||j!=0||k!=0)
{
//making 3/4 and 1/4 pairs
if(j!=0)
{
if(k!=0)
{
if(j==k)
{
count+=k;
j=0;
k=0;
}
min_val=min(j,k);
max(j,k)-=min_val;
min(j,k)=0;
count+=min_val;
}
}
//remaining 3/4 will result in a pizza
if(k!=0)
{
count+=k;
k=0;
}
//making 1/2 pairs
if(i%2==0 && i>0)
{
count+=i/2;
i=0;
}
if(i%2!=0 && i>1)
{
count+=i/2;
i=1;
}
//combining 2 pairs of 1/4
if(j>=4 && j>0)
{
if(j%4==0)
{
count+=j/4;
j=0;
}
else
{
count+=j/4;
j%=4;
}
}
if(i==1)
{
//pair 1/2 with 1/4
if(j>=2)
{
count++;
j-=2;
i=0;
}
else
{
count++;
i=0;
}
}
if (i==0)
{
//pairing last set of 1/4s (<4)
if (j!=0)
{
count++;
j=0;
}
}
if(j!=0)
{
{
//if only 1/4's are left
count++;
j=0;
}
}
}
count++;
printf("%d\n",count);
return 0;
}