I tried all the test cases posted in the comments including the 9th test case, but my code still gives WA while running on the 9th case. Checked the other posts regarding this on the forum but didn't help. Would be appreciated if someone could help.
include
include
using namespace std;
int main() {
int n,i,x,y,z,ans,t,t1;
scanf("%d",&n);
if(n==0)
{
exit(0);
}
else
{
x=0;
y=0;
z=0;
ans=0;
for(i=0;i {
scanf("%d/%d",&t,&t1);
if((t==1)&&(t1==4))
{
x++;
}
else if((t==1)&&(t1==2))
{
y++;
}
else if((t==3)&&(t1==4))
{
z++;
}
}
ans+=z;
ans+=(y/2);
if(x>=z)
{
x=x-z;
ans+=(x/4);
x=x%4;
}
if(y%2==1)
{
ans++;
}
if((x>2)&&(y%2))
{
ans++;
}
if((x>0)&&(y%2==0))
{
ans++;
}
ans++;
printf("%d\n",ans);
}
return 0;
}