MEANMEDIAN - Editorial

oh ok now i got it thanks

MY SOLUTION

Can anyone please explain at what point does my code go wrong?

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

It is printing correct output for every test case still i am getting WA.

I dont know python but i can take a guess:

Take mean =1, median=2

Your output is [0,2,1] whose median is 1 and not 2

Ill give you a test case
X=0 and y=-100

Your output is [0,-100,100] whose median is 0 and not -100

Take this test case

N=0, m=-100

Your output:[0,-100,100]
the median of your output is 0 and not -100

why isn’t this working???

t=int(input())
for _ in range(t):
x,y=map(int,input().split())
if ((3x)-y)%2==0:
f=t=((3
x)-y)/2
else:
f=int(((3x)-y)/2)
t=(3
x)-y-f
print(int(f),int(y),int(t))

I see . Thanks

1 Like

thank you

1 Like

Some test cases are not being able to pass :
here is the code:
int main() {
int t;
cin>>t;
while(t>0){
int x;
int y;
cin>>x>>y;
if(x<=100&&x>=-100&&y<=100&&y>=-100){
int a,b,c;
if(x==y){
a=x;
b=x;
c=x;;
cout<<a<<" “<<b<<” “<<c<<endl;
}
else if(y<0)
{
b=y;
c=0;
a=3x-b;
cout<<a<<" “<<b<<” "<<c<<endl;
}
else
{
a=0;
b=y;
c=3
x-b;
cout<<a<<” “<<b<<” "<<c<<endl;
}
}
t–;
}
return 0;
}

Why this one is wrong can some one explain?

ll t;cin>>t;
while(t--){
    ll x,y; cin>>x>>y;
    if(y>0){
        int a=0, b = y, c=3*x -y;
        cout<<a<<" "<<b<<" "<<c<<endl;
    }
    else if(y<0){
        int a=3*x+y, b = y, c=0;
        cout<<a<<" "<<b<<" "<<c<<endl;
    }
    else if(y==0){
        int a=3*x-1, b = y, c=3*x - a;
        cout<<a<<" "<<b<<" "<<c<<endl;
    }
}
return 0;

}

what is y==0

https://www.codechef.com/viewsolution/73490455
Can anyone tell me whats wrong in this logic…Why is it getting WA?

What’s wrong in this solution?

#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int x,y;
cin>>x>>y;

    cout<<0<<" "<<y<<" "<<(3*x - y)<<" "<<endl;
}
return 0;

}

The output format says: “If multiple answers exist, output any.”

So in one solution, printing three numbers as [0, Y , 3X-Y] should give the correct output.

Why is it showing WA?

Let me know what is missing.
Link: CodeChef: Practical coding for everyone

[CodeChef: Practical coding for everyone]

I don’t understand why i get NZEC. Can anyone please explain what’s wrong in my solution?

here we take the 1st two integer equal i.e. y… but why ?? If I took x,y,3x-y-x then it gives wrong answer

what’s wrong in this … pls tell.

        cin>>x>>y;
        b = y;
        c= b + 800;
        a = (x*3) - c - b;

Can anyone please help me what is wrong with the solution-
Solution: 74029452 | CodeChef

I think only one test case is failing.

I manage to get the solution now…

One query -
Mean - 5, median -5
accepted answer - 5,5,5
WA - 0,5,10 → Why this one is not accepted?
And in the Problem output format, “If multiple answers exist, output any.” is mentioned.