A question from a newbie who doesnt want to quit? HELP

help
easy
help_please
newbie
problem
problems

#1

Been trying the following question and i’ve been getting wrong answers on the codechef compiler, and i have no clue why. Heres my solution and heres the question. https://www.codechef.com/problems/CNOTE . I’m new to competitive coding. It’s hard to figure out a solution when you’re not sure what’s wrong with the code. It works for multiple test cases on other compilers

#include<stdio.h>
int main()
{ long long int tries,ppages,lpages,money,books,a[100000]={0},i,j,temppages,flag=0;
 int price,npages;

 printf("Insert the trails

“);
scanf(”%lld",&tries);

	for(i=0;i<tries;i++)
    {  scanf("%lld %lld %lld %lld",&ppages,&lpages,&money,&books);
        
       if(ppages>lpages){
          
temppages=ppages-lpages;

		for(j=0;j<books;j++)
           {  scanf("%d %d",&npages,&price);
              if (ppages<=(npages+lpages)&&money>=price)
           
                         	a*=1;
              }
          if (a*==1)
          {
          	printf("Luckychef

");
}
else
printf("Unluckychef
");

} }
	/* code */
	return 0;
}

#2

printf("Insert the trails ");

Print ONLY whats specified in output section. It is a machine checking if what you print is an exact match of what the answer is. First remove such superfluous statements. Then, please explain your logic if you still get WA :slight_smile:

Also, you are not printing correct words for answer. Its UnluckyChef not Unluckychef. The judge is case-sensitive. Print EXACTLY what is required.


#3
  1. Remove

printf("Insert the trails
");

In competitive coding we print only the output that is required and nothing else. Also as vijju mentioned print the exact output that is given in question as judge is case-sensitive.

  1. You can remove the if(ppages>lpages) condition as the used pages will be always less than total pages.
  2. Your logic if (ppages<=(npages+lpages)&&money>=price) is wrong. Think again what you want and then rewrite your code. When will chef get Lucky? HInt:
Click to view

When your temppages<=npages && price<= money

If you still need help you can refer to this solution: https://www.codechef.com/viewsolution/19316976