< Back to forum

what's wrong in my solution ??

Hi! I am a beginner at cp. I was tring to solve this question https://www.codechef.com/problems/TWOGRS. I got every correct output( YES/NO ) to every input but still getting wrong answer. so my question is what is wrong in my solution ??

here is my solution

#include<bits/stdc++.h> using namespace std; #define ll long long int

int main() { ll t; cin>>t; while(t--)



{
    ll a,b,c;
    cin>>a>>b>>c;
    
    ll total=0;
    total=(1*a)+(2*b)+(3*c);
    
    if(total%2==0)
    {   
        ll num=total/2;
        ll div=0;
        
        div=num/3;
        num=num-(3* (min(div,c)));
        
        div=num/2;
        num=num-(2* (min(div,b)));
        
        div=num/1;
        num=num-(1* (min(div,a)));
        
        if(num==0)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    else
        cout<<"NO"<<endl;
}


return 0;


}

Asked by: anupam.433454 on March 21, 2020, 7:36 a.m. Last updated on March 21, 2020, 7:38 a.m.


Enter your answer details below:


Preview

Enter your comment details below:

Preview




3 Answer(s)

avatar

Check your solution for

input


1
0 4 4


your output is NO

but

original output is YES

sharshach last updated on March 28, 2020, 4:42 p.m. 0    Reply    Upvote   

avatar

https://www.codechef.com/viewsolution/30837601 Here is my submission. I have just considered 1 more case i.e checked if A,B and C aur are all even then we can simply distribute equally into 2 groups.

There are some cases for which your code is giving NO when count of all variables are even.

hritesh0027 last updated on March 28, 2020, 5:07 p.m.

avatar

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

Here is my submission. I have just considered 1 more case i.e checked if A,B and C aur are all even then we can simply distribute equally into 2 groups.

There might be some large cases for which your code is giving NO when count of all variables are even.

hritesh0027 last updated on March 28, 2020, 5:08 p.m. 0    Reply    Upvote   

avatar

You can also check my solution. It is different from yours: https://www.codechef.com/viewsolution/30843717

anujpatel181299 last updated on March 28, 2020, 7:03 p.m. 0    Reply    Upvote   

Instruction to write good question
  1. 1. Write a title that summarizes the specific problem
  2. 2. Pretend you're talking to a busy colleague
  3. 3. Spelling, grammar and punctuation are important!

Bad: C# Math Confusion
Good: Why does using float instead of int give me different results when all of my inputs are integers?
Bad: [php] session doubt
Good: How can I redirect users to different pages based on session data in PHP?
Bad: android if else problems
Good: Why does str == "value" evaluate to false when str is set to "value"?

Refer to Stack Overflow guide on asking a good question.