PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: Tejas Pandey
Tester: Nishank Suresh, Utkarsh Gupta
Editorialist: Pratiyush Mishra
DIFFICULTY:
To be Calculated
PREREQUISITES:
None
PROBLEM:
N candidates (numbered from 1 to N) join Chef’s firm. The first 5 candidates join on the first day, and then, on every subsequent day, the next 5 candidates join in.
For example, if there are 12 candidates, candidates numbered 1 to 5 will join on day 1, candidates numbered 6 to 10 on day 2 and the remaining 2 candidates will join on day 3.
Candidate numbered K decided to turn down his offer and thus, Chef adjusts the position by shifting up all the higher numbered candidates. This leads to a change in the joining day of some of the candidates.
Help Chef determine the number of candidates who will join on a different day than expected.
EXPLANATION:
Total number of groups of 5 would be:
Total number of groups that won’t be affected:
All the groups that are after the group containing the k_{th} candidate will have 1 person whose joining date will change since he will be shifted to one previous group.
Thus
which is our answer.
TIME COMPLEXITY:
O(1), for each test case.
SOLUTION:
Editorialist’s Solution
Setter’s Solution
Tester1’s Solution
Tester2’s Solution