시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 163 | 49 | 44 | 31.429% |
Aunty Khong is organising a competition with $x$ participants, and wants to give each participant a bag of biscuits. There are $k$ different types of biscuits, numbered from $0$ to $k-1$. Each biscuit of type $i$ ($0 \leq i \leq k-1$) has a tastiness value of $2^i$. Aunty Khong has $a[i]$ (possibly zero) biscuits of type $i$ in her pantry.
Each of Aunty Khong's bags will contain zero or more biscuits of each type. The total number of biscuits of type $i$ in all the bags must not exceed $a[i]$. The sum of tastiness values of all biscuits in a bag is called the total tastiness of the bag.
Help Aunty Khong find out how many different values of $y$ exist, such that it is possible to pack $x$ bags of biscuits, each having total tastiness equal to $y$.
You should implement the following proceedure:
int64 count_tastiness(int64 x, int64[] a)
count_tastiness
, the sum of tastiness values of all biscuits in the pantry does not exceed $10^{18}$.Consider the following call:
count_tastiness(3, [5, 2, 1])
This means that Aunty wants to pack $3$ bags, and there are $3$ types of biscuits in the shop:
The possible values of $y$ are $[0, 1, 2, 3, 4]$. For instance, in order to pack $3$ bags of total tastiness $3$, Aunty can pack:
Since there are $5$ possible values of $y$, the procedure should return $5$.
Consider the following call:
count_tastiness(2, [2, 1, 2])
This means that Aunty wants to pack $2$ bags, and there are $3$ types of biscuits in the shop:
The possible values of $y$ are $[0,1,2,4,5,6]$. Since there are $6$ possible values of $y$, the procedure should return $6$.
번호 | 배점 | 제한 |
---|---|---|
1 | 9 | $q \leq 10$, and for each call to |
2 | 12 | $x = 1$, $q \leq 10$ |
3 | 21 | $x \leq 10\;000$, $q \leq 10$ |
4 | 35 | The correct return value of each call to |
5 | 23 | No additional constraints. |
Olympiad > International Olympiad in Informatics > IOI 2020 > Day 2 4번
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)