Alex - Treasure Hunt
Single File Programming Question
Problem Statement
Alex is a treasure hunter who collects valuable items during their quests. Each item has a specific point value, and Alex wants to maximize their score by strategically removing items one at a time. The rule is simple: Alex removes the item with the highest point value in each step until no items are left, summing the values of the removed items to calculate the maximum score. Help Alex to complete his task.
Input:
format :The first line of input consists of an integer N, representing the size of the array. The second line of input consists of N space-separated integers, representing the point values of the items.
Output:
format :The output prints "Maximum Sum: " followed by the calculated maximum score after removing all items. Refer to the sample output for formatting specifications. Code constraints : 1 ≤ N ≤ 20 Sample test cases :
Input 1:
14 7 14 21 28 35 42 49 56 63 70 77 84 91 98
Output 1 :
Maximum Sum: 735
Input 2 :
6 5 4 3 2 1 0
Output 2 :
Maximum Sum: 15
Input 3 :
4 -5 -10 -15 -20
Output 3 :
Maximum Sum: -50