NWERC24-076.Dutch Democracy
Hard · 2 s · 256 MB
- icpc
- nwerc
- 2024
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.
Giriş formatı
The input consists of:
• One line with an integer (), the number of parties.
• One line with integers (), the number of seats each party has.
Çıxış formatı
Output the total number of candidate coalitions that satisfy the criteria above.
Qeyd
Source: Northwestern Europe Regional Contest (NWERC) 2024 · Author: Thomas Beuman · License: CC BY-SA 4.0 · Original: https://2024.nwerc.eu · Statement adapted for AlgoLens and shared under the same license. · 8 of the 128 original test cases (the largest) are omitted here to keep the problem lightweight.
Nümunələr
Giriş #1
5 3 1 4 1 5
Çıxış #1
4
Giriş #2
11 191 24 148 38 8 28 9 1 3 3 12
Çıxış #2
38
Giriş #3
4 1 2 3 4
Çıxış #3
3