Codeforces WA (A. Three Pairwise Maximum) Div 3

Problem = Problem Link

My solution = Solution

My Answer is matching with the testcases. Checked on Ideone And Vim.

Here is my solution, you can take help from it.
My Solution

Could you explain why sorting was used in your program?

The problem says a, b, c should be Positive integers so you cannot print 0, you’ve printed 0 on the 5th case

Feel sorry for you, everyone makes such dumb mistakes at some point.
It took me 40 minutes to realize I was printing “-1” instead of “NO” in this problem. :frowning:

5 Likes

You can see the test case infromation. You have printed 0 as b, when b should be >= 1.

Out of contest: Why are you defining a custom sort, when you can use the std::sort.
P.S: If anyone wants to see that donkey work I did -> Link

Are you quoting @i_64 ?

1 Like

xD. Indeed.

This is what I do

def solve():
    l=list(map(int,input().split()))
    if l[0]==l[1] and l[0]==l[2]:
        print("YES")
        print(*l)
    else:
        if l.count(max(l))==2:
            print("YES")
            x=list(set(l))
            print(1,*x)
        else:
            print("NO")
            
       
for _ in range(int(input())):
    solve()

This is what I did …you can take help from it .
https://codeforces.com/contest/1385/submission/87117034

Solution A
Solution B
Solution C
Solution D
Solution E

Sorting just reduces the number of if conditions.

If the largest number occurs twice, answer is max, min, min.
If all are same, print all of them, otherwise answer is “NO”.

1 Like

I don’t know why but I did take longer than expected to solve this problem. Is it just me?

Just sort in decreasing order. Check if first and second numbers are equal , if yes print first,third,third else “NO”