PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
Chef needs one set of clothes every day for N days.
A set of clothes worn and washed on day X will be next available on day X+7.
How many distinct sets of clothes are needed?
EXPLANATION:
If N \le 7, there’s not enough time for clothes to return after being washed.
So, every day needs a separate set of clothes.
The answer is hence N.
For N \gt 7 however, the clothes will start returning after being washed.
For instance, the same set worn on day 1 can be worn on day 8, the same set worn on day 2 can be worn on day 9, and so on.
So, only 7 sets of clothes are needed - one each for days 1, 2, \ldots, 7.
Every further day doesn’t need a new set - an older set will instead be available after washing.
Hence, the answer is N when N \le 7 and 7 with N \gt 7.
This can be written as \min(N, 7).
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
n = int(input())
print(min(n, 7))