Lower Algorithmics
Time limit4sMemory limit512 MB
Count the distinct positive integers that can be written as a sum of between l and r elements of set A, with repetition allowed.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Bit manipulation
- Solved
- No attempts yet
Problem
You are given a set of integers from to inclusive. Your task is to find the number of positive integers that can be represented as a sum of several elements of , with number of summands being from to inclusive. Equal summands are allowed. Note that each number is counted only once, even if it has several such representations.
Input
The first line of the input contains three space-separated integers: , the number of elements in (), followed by and , the bounds on number of summands (). The second line contains space-separated integers (): the elements of the set in increasing order.
Output
Output the number of integers that are representable as a sum of elements of , with number of summands being between and .