| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 86 | 38 | 32 | 46.377% |
The king of Kaldoria traditionally celebrates his birthday by inviting the knights of his realm to a big jousting tournament, and every noble house participates by sending their best knights to win fame and glory. At the end of the tournament, the king does not only choose a winner but ranks all $n$ knights from worst to best.
The number of knights belonging to house $i$ is denoted by $k_i$. Each knight serves at most one house. There can be knights who do not serve any house. The houses are ordered by their influence in the kingdom (with the first one being the most influential). If the $k_1$ knights of the most powerful house take the last $k_1$ places in the tournament, the house will incite a revolt against king and crown. The members of the second most influential house are not that powerful. Even if all its $k_2$ knights end up at the bottom of the ranking, it would be considered a strong provocation but the house would not be able to start a revolt. However, if the last $k_1 + k_2$ places are taken by all the knights of the two most influential houses combined, then the two houses will unite and start fighting the king. More generally, if the knights of the $\ell$ most powerful houses occupy the last $k_1 + k_2 + \dots + k_\ell$ places in the tournament, they will unite and incite a revolt.
Of course, a revolt has to be avoided at all cost. Knowing that the king often chooses the ranking spontaneously and without too much consideration, the chief mathematician of the crown has been tasked with analysing how many rankings will not lead to a revolt.
The input consists of:
It holds that $\sum_{i=1}^h k_i \leq n$.
Output the number of rankings that do not lead to a revolt. As this number can be quite large, it should be output modulo 10ドル^9+7$.
3 0
6
4 1 3
18
4 2 2 1
16
ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2023 K번