Coalitions | 프로그래밍의 벗 PivotOJ
PivotOJ

Coalitions

시간 제한: 3000ms메모리 제한: 1024MB출처: EIO 2019-20 openBOJ 29915

문제

There are NN members in the parliament, and each one of them is a representative of one of the KK parties. Now the parties have to form a ruling colation.

For a coalition to be able to rule, it needs a majority in the parliament. On the other hand, the more parties in the coalition, the less stable it is because of possible differences of opinion. Thus, a coalition that would still have a majority in the parliament after excluding some of the parties in it is not very sensible.

More precisely, a group of parties can form a stable coalition under two conditions:

  1. Together, the parties in the coalition have more than N2\frac{N}{2} members of the parliament.
  2. If any of the parties were excluded from the coalition, the remaining ones would no longer have more than N2\frac{N}{2} members of the parliament.

Count the number of possible groups that could form stable coalitions.

입력

The first line of input contains NN, the number of seats in the parliament, and KK, the number of parties (1N10181 \le N \le 10^{18}, 1K361 \le K \le 36). The second line contains KK integers M1M_1, M2M_2, \ldots, MKM_K (1MiN1 \le M_i \le N), where MiM_i is the number of members of the parliament in the ii-th party. It is guaranteed that M1+M2++MK=NM_1 + M_2 + \cdots + M_K = N.

출력

The only line of output should contain a single integer: the number of possible stable coalitions.

예제

예제 1

입력
14 5
6 2 1 4 1
출력
4

예제 2

입력
8 8
1 1 1 1 1 1 1 1
출력
56

예제 3

입력
101 6
34 25 19 12 10 1
출력
5
코드를 제출하려면 로그인하세요.