SQUATS - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: Prakhar Agarwal
Testers: Hriday, Utkarsh Gupta
Editorialist: Nishank Suresh

DIFFICULTY:

249

PREREQUISITES:

None

PROBLEM:

Somu did X sets of 15 squats each. How many squats did he do?

EXPLANATION:

Since each set consists of 15 squats and there are X sets, the total number of squats is 15\cdot X.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    print(15*int(input()))

What should the function return if the inputs are out of constraints?

Your code fails to detect when T less than 0, or X < 0.
Imagine Somu did -1 set of squats, i.e. -15 squats. Did he just jump?

This problem has constrains listed at the end. I don’t think you guys testing for constrains at all.

My code checks for input constrains and throws error when input is out of constrains. It returns what are expected. And my code failed for submission. Go figure!!

Your code fails because it checks for X\leq 10^4, while the constraints say X\leq 10^5.

Also, in general in competitive programming tasks it’s unnecessary to check whether the input satisfies the constraints: the constraints are there to tell you that they will be satisfied for any input your program receives. The problem’s author will ensure this.

This is why you’ll not find my code (or almost every other somewhat experienced contestant’s code, for that matter) checking whether the constraints are satisfied.