AOTGAME - Editorial

PROBLEM LINK: Eren and Armin

Author: Jeevansh Gagroo
Tester: Tanay Morakhia
Editorialist: Jeevansh Gagroo

DIFFICULTY
Medium

PREREQUISITES
Knowledge of Basic Programming,Sorting and Searching Techniques, Binary Search

EXPLANATION

Some Observations:

  • Given the Number of Games and Hours Taken to complete each game, we first of all calculate the Total Hours taken by a single person to play the game, which would be the sum of all the hours given (consider this to be SUM), this would be the minimum time taken by a person to play the game.
  • If two players have to play the same set of games in minimum time, then if the TWICE of the Maximum Hours taken to complete a game is larger than SUM (of hours taken to complete each games), then our answer is TWICE of the Maximum Hours.
  • If the TWICE of the Maximum Hours taken to complete a game is smaller than SUM(of hours taken to complete each games), then our answer is the SUM(sum of Hours Taken to complete each game).

For Example: If two players are supposed to play 3 games, and to complete each game it takes 2,8 and 3 hours respectively, the Twice of maximum time taken to complete a game is 2*8 = 16 and sum of hours to complete all the games is 2+8+3 = 13 which is less than 16, therefore our answer is 16(which is twice of the maximum time taken to complete a game).

For better explanation refer: Explanation

SOLUTION

C++ Solution: Eren and Armin C++ Solution
Python Solution: Eren and Armin Python Solution
Java Solution: Eren and Armin Java Solution