ACS - EDITORIAL

PROBLEM LINK:

Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4

Setter: abhi_inav
Testers: inov_360, iceknight1093
Editorialist: hrishik85

DIFFICULTY:

739

PREREQUISITES:

None

PROBLEM:

There are 10 problems in a contest. We know that the score of each problem is either 1 or 100 points. Kindly note here that there will also be some unsolved problems - for unsolved problems, the score is 0.
Given the total score ‘P’ of a participant, we have to determine the number of problems solved by the participant. We print ‘-1’ in case the score is invalid

EXPLANATION:

Let’s assume the following
X - solved problems with 100 points, Y - solved problems with 1 point, Z - unsolved problems
The score of the participant is P = 100 * X + 1 * Y
We also know that P <= 1000 and total problems are 10
Given the points above, the condition setup is X = P//100 and Y = P%100
We need to output (P//100 + P%100) - this will be the total questions solved correctly

TIME COMPLEXITY:

Time complexity is O(1).

SOLUTION:

Tester's Solution
for _ in range(int(input())):
	p = int(input())
	ans = p%100 + p//100
	if ans > 10:
		print(-1)
	else:
		print(ans)
Editorialist's Solution
t=int(input())
for _ in range(t):
    P = int(input())
    if ((P//100) + (P%100))<=10:
        print((P//100) + (P%100))
    else:
        print(-1)