Attendu December cook-off question help

#include <stdio.h>

int main()
{
int t;
scanf("%d",&t);
if(t>=1&&t<=10)
{
while(t>0)
{
int n;
scanf("%d",&n);
if(n>=1&&n<=120)
{
char b[n];
int c1=0,c2=0,i;
float s;
scanf("%s",b);
for(i=0;i<n;i++)
{
if(b[i]==‘0’)
{
c1=c1+1;
}
if(b[i]==‘1’)
{
c2=c2+1;
c1=c1+1;
}
}
if(c1==n)
{

            if((120-n+c2)>=90)
            {
                printf("Yes\n");
            }
            else if((120-n+c2)<90)
            {
                printf("No\n");
            }
            }
            c2=0;
            c1=0;
        }
        t=t-1;
    }
}

return 0;

}

I get output same as in question but whenever I tried
to submit this solution codechef shows wrong answer, please help me

YES and NO are in capital letters :).
and try to reduce redundancy mate

Thanks

Can you tell me here redundancy?

int leaves = 0;
for (int i = 0; i < n; i++) 
	leaves += (b[i] == '0');

if (leaves > 30)
	cout << "NO\n";
else
	cout << "YES\n";

He means try to write short and precise code. :))

1 Like