Submit solution

Points: 7 (partial)
Time limit: 1.2s
Memory limit: 128M

Author:
Problem type

It's that time in Tssojistan, time to elect a new HacKing! (yes, kings are elected here, don't ask questions) The "democratic" voting takes place by dividing all the citizens into groups based on their programming language, and having each group vote at different times throughout the election day (as groups like C++ and Java are known to not get along).

Moreover, strictly half of the groups will vote at Benum's Booth while the other half will vote at Naccarato's Nook. This is to lower waiting and queue times at each booth, as programmers are very stingy about being efficient. After votes from station have been counted, if a certain candidate wins a strict majority of individual votes from both stations, they will be crowned the new HacKing. Otherwise, the current HacKing will remain on the throne.

EgorGor is the only candidate running this year against the curent HacKing, Serog1sPerog1s. However he is quite concerned about his campaign. He fears he hasn't garnered enough support to overthrow Serog1sPerog1s, as his blinding scalp seems to scare away a significant part of the population. And so, being the sneaky sasquatch he is, he comes to you for help with his plan to sabotage the election.

With the help of sankeeth_ganeswaran and his family of computer scammers, EgorGor has managed to collect the voter info for every voting group in Tssojistan, and knows for certain who they will vote for on election day. He plans to rig the election by reassigning the groups and their designated voting booths to give himself a favourable advantage, while still making sure each booth has strictly half of the groups. He needs you to calculate how many unique pairs of votes from both booths that he can become the HacKing with, by reassigning the groups.

Input Specification

The first line of the input will contain an integer V, representing the number of voters per group.

The second line of the input will contain an even integer G, representing the number of total groups.

The third line will contain G integers A_i denoting the amount of citizens who voted for EgorGor in group i.

Constraints

1 \le V, G \le 20

1 \le A_i \le V

Output Specification

The number of unique pairs of votes from the 2 booths that will allow EgorGor to win. If there is no way he can win, output oh boo hoo.

Sample Input 1

5
4
2 3 3 4

Sample Output 1

1

Explanation

EgorGor can only win a strict majority at both booths if he sends the group with 4 and 2 supporters to one booth, and the groups with 3 supporters to the other, as both booths will have a majority with 6/10 of voters for EgorGor.

Sample Input 2

5
8
2 4 2 3 3 3 3 3

Sample Output 2

1

Explanation

A solution is to send the first 4 groups to one booth and the last 4 to the other for a majority of 11/20 in one booth and 12/20 in the other. All other solutions will also have 11 votes from a booth and 12 in the other, so they are not unique from this one.

Sample Input 3

8
10
3 5 5 5 2 8 6 6 3 4

Sample Output 3

3

Explanation

The 3 unique pairs are (21, 26), (22, 25), and (23, 24).

Sample Input 4

11
15
2 2 3 4 4 6 7 3 10 9 10 4 5 3 9

Sample Output 4

oh boo hoo

Explanation

oh boo hoo


Comments

There are no comments at the moment.