# JOINING Editorial

Setter: Tejas Pandey
Tester: Nishank Suresh, Utkarsh Gupta
Editorialist: Pratiyush Mishra

To be Calculated

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 = \lfloor \frac{n+4}{5} \rfloor

Total number of groups that won’t be affected:

unaffected = \lfloor \frac{k+4}{5} \rfloor

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

affected = total - unaffected

which is our answer.

# TIME COMPLEXITY:

O(1), for each test case.

1 Like