Dutch Democracy

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

요약
의석 합이 과반수를 넘으면서 어떤 정당을 빼도 과반수가 깨지는 연합의 수를 센다.
난이도

보통10점 중 6점

유형
동적 계획법, 조합론, 정렬
정답자
아직 제출이 없습니다

문제

The process of forming the Dutch government has taken more than half a year for three elections in a row. Perhaps we can streamline the initial stages of coalition building?

The first step after the election results is to find a group of parties (called a coalition) with enough seats to have a strict majority. Your task is to count the number of candidate coalitions that satisfy specific conditions. A coalition is considered a candidate coalition if it meets these two criteria:

Strict Majority: The total number of seats held by the coalition must be strictly more than half of the total seats across all parties.

No Superfluous Parties: The coalition must be minimal in the sense that removing any one party from the coalition would cause it to lose its strict majority.

Figure D.1: Illustration of Sample Input 2.

입력

The input consists of:

  • One line with an integer nn (1≤n≤601 \le n \le 60), the number of parties.
  • One line with nn integers pp (1≤p≤10,0001 \le p \le 10\\,000), the number of seats each party has.

출력

Output the total number of candidate coalitions that satisfy the criteria above.

예제3

  1. 예제 1

    입력
    5
    3 1 4 1 5
    
    예상 출력
    4
    
  2. 예제 2

    입력
    11
    191 24 148 38 8 28 9 1 3 3 12
    
    예상 출력
    38
    
  3. 예제 3

    입력
    4
    1 2 3 4
    
    예상 출력
    3