The topic super water, but the topic meaning is not well understood (English is too poor ... ), order, and the answer comes out.
Democracy in danger
Time Limit: 1000MS |
|
Memory Limit: 65536K |
Total Submissions: 3136 |
|
Accepted: 2311 |
Description
In one of the countries of Caribbean basin all decisions were accepted by the simple majority of votes on the general meet ing of citizens (fortunately, there were no lots of them). One of the local parties, aspiring to come to power as lawfully as possible, got its on putting into effect some refor M of the election system. The main argument was, the population of the island recently had increased and it is to longer easy-to-hold general m Eetings.
The essence of the reform is as follows. From the moment to its coming to effect all the citizens were divided to K (May is not equal) groups. Votes on every question were to being held then in each group, moreover, the group is said to vote ' for ' if more than half O F The group had voted "for", otherwise it is said to vote "against". After the voting in each group a number of group that had voted "for" and "against" is calculated. The answer to the question is positive if the number of groups that had voted "for" is greater than the half of the gene RAL number of groups.
At first the inhabitants of the accepted this system with pleasure. But when the first delights dispersed, some negative properties became obvious. It appeared that supporters of the party, which had introduced this system, could influence upon formation of groups of Vot ERs. Due to the they had an opportunity to put in effect some decisions without a majority of voters "for" it.
Let ' s consider three groups of voters, containing 5, 5 and 7 persons, respectively. Then it's enough for the party has only three supporters in each of the first and groups. So it would is able to put in effect a decision with the help of only six votes ' for ' instead of nine, that's would. Be NE Cessary in the case of general votes.
You is to write a program, which would determine according to the given partition of the electors the minimal number of S Upporters of the party, sufficient for putting to effect of any decision, with some distribution of those supporters Amo ng the groups.
Input
The input of this problem contains the lines. In the first line a only natural number K <= 101-a quantity of Groups-is written. The second line there is written K natural numbers, separated with a space. Those numbers define a number of voters in each group. In order to simplify the notion of "the majority of votes" We'll say that number of groups also as the number of voter s in each group is odd. Also consider, the population of the island does not exceeds 10001 persons.
Output
You should write a only natural number-a minimal quantity of supporters of the party, so can put into effect any deci Sion.
Sample Input
35 7 5
Sample Output
6
Source
Ural State University Internal Contest October ' Junior Session
1 //Oimonster2#include <cstdio>3#include <cstdlib>4#include <iostream>5 using namespacestd;6 inta[10001];7 voidQsortintS[],intLintR)8 {9 intT;Ten inti = l, j = r, x = s[(i+j)/2]; One Do A { - while(x>S[i]) -i++; the while(x<S[j]) -j--; - if(I <=j) { -t=S[i]; +s[i]=S[j]; -s[j]=T; +i++; Aj--; at } -} while(i<j); - if(l<j) - qsort (s,l,j); - if(i<R) - qsort (s,i,r); in } - intMain () { to intI,j,n; +scanf"%d",&n); - for(i=1; i<=n;i++){ thescanf"%d",&a[i]); * } $Qsort (A,1, n);Panax Notoginseng intans=0; - for(i=1; I<= (n+1)/2; i++){ theans+= (a[i]+1)/2; + } Aprintf"%d\n", ans); the return 0; +}
View Code
POJ2370 Democracy in danger