Clash of Coders CLCO05 - Editorial

PROBLEM LINK:

Practice

Contest

Author: Chahak Gupta

Tester: Rahul Johari

DIFFICULTY:

EASY-MEDIUM

PREREQUISITES:

Maths, Scheduling

EXPLANATION:

For checking whether there is a way to eat all dishes by Harry, we can make the optimal time schedule in the following way.

•	First Harry will eat the dish.
•	Then during 10 minutes rest of Harry, Joseph will crack 2 jokes(each of 5 minutes)
•	Then Harry will again eat a dish, then Joseph, etc.
•	After Harry has completed all his dishes, Joseph will keep on cracking jokes of 5 minutes each.

Hence minimum duration of the even needed such that Harry could eat all his dishes will be t1 + 10 + t2 + 10 + … + tn = sum + (n - 1) * 10 where sum denote the total time of the eating all the dishes (sum of array).

So for checking feasibility of the solution, just check whether sum + (n - 1) * 10 ≤ duration of event or not?.

If it is feasible, then time remaining for Joseph will be the entire duration except the time when Harry is eating all the dishes. Hence time available for Joseph will be duration - sum. In that time Joseph will crack (duration - sum)/5 jokes.

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found link text.

//