아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Coalitions

시간 제한3초메모리 제한1024 MB

요약
의석 합이 N의 절반을 넘으면서, 어느 한 정당을 빼면 합이 다시 절반 이하로 떨어지는 정당 집합의 수를 센다.
난이도

보통10점 중 6점

유형
비트 연산, 완전 탐색, 조합론, 그리디
정답자
아직 제출이 없습니다

문제

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 (1≤N≤10181 \le N \le 10^{18}, 1≤K≤361 \le K \le 36). The second line contains KK integers M_1M\_1, M_2M\_2, …\ldots, M_KM\_K (1≤M_i≤N1 \le M\_i \le N), where M_iM\_i is the number of members of the parliament in the ii-th party. It is guaranteed that M_1+M_2+⋯+M_K=NM\_1 + M\_2 + \cdots + M\_K = N.

출력

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

예제3

  1. 예제 1

    입력
    14 5
    6 2 1 4 1
    
    예상 출력
    4
    
  2. 예제 2

    입력
    8 8
    1 1 1 1 1 1 1 1
    
    예상 출력
    56
    
  3. 예제 3

    입력
    101 6
    34 25 19 12 10 1
    
    예상 출력
    5