Given N advertisements with click costs and a limit L, find the maximum number of clicks that can be used to select exactly X advertisements such that the total number of clicks is strictly less than L.
Example 1:
Input:3
1 2 3
2
5
Output:4
Example 2:
Input:5
1 2 3 4 5
3
10
Output:6
Example 3:
Input:1
1
1
1
Output:0
Constraints:
1 ≤ N < 10
1 ≤ S ≤ N
1 < L < 10^6
1 ≤ a < L
solution.cpp
Loading...
Run code to see test results
00:00 / 69:42
Maximum Clicks Within Limit
MediumMed•342 views
Given N advertisements with click costs and a limit L, find the maximum number of clicks that can be used to select exactly X advertisements such that the total number of clicks is strictly less than L.