MEANMEDIAN - Editorial

Consider a case like y = 0 and x = 100. Your initial solution computes
b = 0
c = 1
a = 299

The median of this set isn’t 0.

1 Like

https://www.codechef.com/viewsolution/73432127
Here is my solution.
I don’t understand why i get wa. Can anyone please explain what’s wrong in my solution?

1 Like

can u please tell me why I am getting WA
here is my solution

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

Check for mean=2,median=1, your output is 3,1,2 and the median of your output is 2 and not 1

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?