/Cricket-League-Problem

Maximum sum of an array taking no 3 elements in a row

Primary LanguagePythonMIT LicenseMIT

Cricket-League-Problem

Maximum sum of an array taking no 3 elements in a row

Problem

In a cricket league, the amount that each players is paid varies from match to match. The match fee depends on the quality of opppsition, the venue and etc. The match fees for each match in the new season have been announced in advance. Each team has to enforce a mandatory rotation policy so that no player ever plays three matches in a row during the season. Vijay is the captain and chooses the team for each match. He wants to allocate a playing schedule for himself to maximize his earnings through match fees during the season.

Input Format

  • Line 1 : A single integer N, which is the number of games in the league season
  • Line 2 : N non-negative integers, where the integer in position i represents the fee for match i

Output format

The output consists of a single non-negative integer, which is the maximum amount of money that Vijay can earn during this season.

Examples

  • Sample Input 1

    • 5 (10 3 5 7 3)
  • Sample Output 1

    • 23 (Explanation: 10+3+7+3)
  • Sample Input 2

    • 8 (3 2 3 2 3 5 1 3)
  • Sample Output 2

    • 17 (Explanation: 3+3+3+5+3)