CLIPLX - Editorial

PROBLEM LINK

Practice
Contest

Author: Avijit Agarwal
Tester and Editorialist: Soumik Sarkar

DIFFICULTY

Cakewalk

PREREQUISITES

None

PROBLEM

X points are required from Y matches. For each match, a loss gives 0 points, a tie gives 1 point and a win gives 2 points. Gather X points using minimum number of wins.

EXPLANATION

If X \leq Y, it is possible to tie X matches and get the required points.
If X > Y, one must win exactly X - Y matches and tie the rest.

The answer can be expressed as \max(0, X - Y).

Time complexity is \mathcal{O}(1) per case.

AUTHOR’S AND TESTER’S SOLUTIONS

Author’s solution can be found here.
Tester’s solution can be found here.

1 Like

#what’ s the problem in this code, you didn’t notice one condition is that , for 3 and 5 case : 2
for i in range (int(input())):
r,x=map(int,input().split())
f=r/2
if f<1:
print(“0”)
elif r%2==0:
print(int(f))
else:
h=r+1
p=h/2
if p>1:
print( int§ )

1 Like