 New update is available. Click here to update.

# Mario And His Princess

Contributed by
Last Updated: 23 Feb, 2023
Medium 0/80
Avg time to solve 25 mins
Success Rate 65 % Share 0 upvotes

## Problem Statement

#### Example:

``````Input: 'N' = 5, 'DIAMOND' = [1, 2, 3, 4, 5]

Output: 9

Mario can take the following combinations of DIAMOND without getting burn:-
1, 3, 5 = 1 + 3 + 5 = 9.
1, 4 = 1 + 4 = 5
1, 5 = 1+5 = 6
2, 4 = 2+4 = 6
2, 5 = 2+5 = 7
3, 5 = 3+5 = 8

Also, he can take all the DIAMOND uniquely as well means he takes DIAMOND from the single dragon but the max DIAMOND he can get is 9.
``````
Detailed explanation ( Input/output format, Notes, Images ) ##### Sample Input 1 :
``````2
5
1 2 3 4 5
5
1 1 1 1 1
``````
##### Sample Output 1 :
``````9
3
``````
##### Explanation Of Sample Input 1 :
``````For the first case:
Mario can take the following combinations of DIAMOND without getting burn:-
1, 3, 5 = 1+3+5 = 9.
1, 4 = 1+4 = 5
1, 5 = 1+5 = 6
2, 4 = 2+4 = 6
2, 5 = 2+5 = 7
3, 5 = 3+5 = 8
Also, he can take all the DIAMOND uniquely as well means he takes DIAMOND from the single dragon but the max DIAMOND he can get is 9.

For the second case:
Anyhow Mario takes the diamond he can at most 3 DIAMOND by taking DIAMOND from 1, 3, and 5.
``````
##### Sample Input 2 :
``````2
2
1 2
4
1 2 3 4
``````
##### Sample Output 2 :
``````2
6
``````  Auto Console