logo AlgoBeat OnlineJudge
登录 注册

#213844. [NWERC 2024] Dutch Democracy

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

:::align{center}

Figure D.1: Illustration of Sample Input 2.

:::

输入格式

The input consists of:

  • One line with an integer (), the number of parties.
  • One line with integers (), the number of seats each party has.

输出格式

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

样例

样例输入 1

5
3 1 4 1 5

样例输出 1

4

样例输入 2

11
191 24 148 38 8 28 9 1 3 3 12

样例输出 2

38

样例输入 3

4
1 2 3 4

样例输出 3

3