Oranges
Rookie SRM 15 · 2022-07-04 · by erinn
Problem Statement
You are at the store purchasing some oranges, which are sold in bags. Each bag has a quantity of oranges in it, given in
Constraints
- bags will contain between 1 and 50 elements, inclusive.
- Each element of bags will be between 1 and 10, inclusive.
{ 1, 2, 3 }
Returns: 6
Since each bag has a different number of oranges, we can take all of them.
{ 5, 2, 5, 3 }
Returns: 10
We take a bag of 2, a bag of 3, and a bag of 5.
{ 3 }
Returns: 3
There's only one bag to take.
{ 4, 4, 4, 4, 4, 4, 4 }
Returns: 4
Since all the bags are the same size, we can only take one of them.
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Returns: 55
Submissions are judged against all 6 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Oranges with a public method int maximum(vector<int> bags) · 6 test cases · 2 s / 256 MB per case