CHECHOC - Editorial

Thanks @satyam_patidar

1 Like

Hi.
Can someone plz tell me the test case where my code is giving the wrong ouput
heres my submission

https://www.codechef.com/viewsolution/35965722

I am assigning max values matrix can have and then I am summing all the elements of matrix

I think we should have all the test cases with their answers to verify our codes and able to know in which test cases our code gives a wrong answers. Do you agree?

@rajarshi_basu @cherry0697 @yash_chandnani

**what is wrong in my code can anyone tell **

#include<bits/stdc++.h>
using namespace std ;

int main ()
{
int t;
cin>>t;
while(tā€“)
{
long long int n,m,k,y;
cin>>n>>m>>k>>y;
if(y>=k)
{
if((y-k)>=k)
cout<<kmn<<endl;
else{
if(m%2==0)
cout<<(m/2)yn<<endl;

    else
    {
        if(y<k)
    {
       int j=(m-1)/2;
        cout<<(j*y+y)*n<<endl;
    }
    
    else
        {
        int j=(m-1)/2;
        cout<<(j*y+k)*n<<endl;
        }      

    } 
    }    
  }
}
return 0;

}

Hey can anyone please tell me what is wrong with this code.
Any help would be great. Thanks in advance! :slight_smile:
https://www.codechef.com/viewsolution/36065195

Can plzz anyone explain what is the problem with my code. CodeChef: Practical coding for everyone

can anyone please tell whatā€™s wrong with my code?? (PS: Iā€™m a n00b)
https://www.codechef.com/viewsolution/36078979

there r many mistakes first if n!=1 &&m!=1
if yx then u should fill with max(x,y-x) not x
and there ws also missing endl at line 26
refer to my sol
https://www.codechef.com/viewsolution/36025844

for _ in range(int(input())):

N,M,X,Y = map(int,input().split())

if (N*M) == 1:

    max_candies = min(X,Y)

elif X >= Y:

    big = Y

    if (N*M) % 2 == 0:

        max_candies = ((N*M)//2) * big

    else:

        max_candies = (((N*M)//2)+1) * big



else:

    i = Y//2

    j = Y - i

    if (N*M) % 2 == 0:

        max_candies = (((N*M)//2) * i) + (((N*M)//2)* j)

    else:

        max_candies = ((((N*M)//2)+1) * j) + (((N*M)//2) * i)

print(max_candies)

my answer is correct when i run in my ide but wrong when i submit.
HELP ME HERE !!

Whats wrong with my codeā€¦Can anyone help meā€¦it,s eating my daysā€¦:expressionless:
https://www.codechef.com/viewsolution/36082594

You logic is greatā€¦ Did you deduce it on your own? I canā€™t even think like thisā€¦ Or did u see from other editorials? I understood the formula but :confused: ā€¦

no i saw it frm a video

Which one???

In if(x==1&&y==1) condition you didnā€™t use endline otherwise your solution works fine

sry bro i remebered just nw i saw frm succesful submissions

https://www.codechef.com/viewsolution/36099975
can somebody help me in this . All sample test cases are getting passed , but on submission , I am getting WA as result.

Thanks, I got it.

https://www.codechef.com/viewsolution/36102489

someone please tell me where i am wrong.

#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int t;
scanf("%d",&t);
while(tā€“)
{
long long int n,m,x,y;
scanf("%lld %lld %lld %lld",&n,&m,&x,&y);

	long long int matrix=n*m;
		
	
	if(y<=x)
	{
	   if(n==1 && m==1)
		printf("%lld\n",x);
	
    else if(matrix%2==0)
	printf("%lld\n",((matrix/2)*y));
	
	else if(matrix%2!=0)
	printf("%lld\n",((matrix/2+1)*y));
	}
	
	else
	{
	    if(n==1 && m==1)
		printf("%lld\n",x);
		
	else if(matrix%2==0)
	{
	    
     if(2*x>=y) printf("%lld\n",((matrix/2)*x)+((matrix/2)*(y-x)));
	else printf("%lld\n",matrix*x);}
	
	
	else if(matrix%2!=0)
	if(2*x>=y) printf("%lld\n",((matrix/2+1)*x)+((matrix/2)*(y-x)));
	else printf("%lld\n",matrix*x);
	    
	}
	
}

return 0;
}

CodeChef: Practical coding for everyone Can anyone tell me what is wrong with this submission?