PROBLEM 22: Three Pairwise Maximums
Problem Reference : Codeforces
You are given three positive (i.e. strictly greater than zero) integers , and .
Your task is to find positive integers , and such that , and , or determine that it is impossible to find such , and .
You have to answer independent test cases. Print required , and in any (arbitrary) order.
Input:
The first line of the input contains one integer () — the number of test cases. Then test cases follow.
The only line of the test case contains three integers , , and ().
Output:
For each test case, print the answer:
- "NO" in the only line of the output if a solution doesn't exist;
- or "YES" in the first line and any valid triple of positive integers , and () in the second line. You can print , and in any order.
Solution:
- t = int(input())
- i = 0
- l = []
- while i < t :
- i = i + 1
- l = []
- x1,y1,z1 = input().split()
- x = int(x1)
- y = int(y1)
- z = int(z1)
- l.append(x)
- l.append(y)
- l.append(z)
- l.sort()
- if l[1] != l[2]:
- print("NO")
- else:
- print("YES")
- print(l[0],l[0],l[2])
The above solution is in python language.
Example
input
5 3 2 3 100 100 100 50 49 49 10 30 20 1 1000000000 1000000000
output
YES 3 2 1 YES 100 100 100 NO NO YES 1 1 1000000000
No comments:
Post a Comment