zoukankan      html  css  js  c++  java
  • POJ2370 Democracy in danger

    题目超级水,但题目意思不好理解(英语太差。。。),排个序,然后答案就出来了。

    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 at the general meeting 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 way in putting into effect some reform of the election system. The main argument was that the population of the island recently had increased and it was to longer easy to hold general meetings. 
    The essence of the reform is as follows. From the moment of its coming into effect all the citizens were divided into K (may be not equal) groups. Votes on every question were to be held then in each group, moreover, the group was said to vote "for" if more than half of the group had voted "for", otherwise it was said to vote "against". After the voting in each group a number of group that had voted "for" and "against" was calculated. The answer to the question was positive if the number of groups that had voted "for" was greater than the half of the general number of groups. 
    At first the inhabitants of the island accepted this system with pleasure. But when the first delights dispersed, some negative properties became obvious. It appeared that supporters of the party, that had introduced this system, could influence upon formation of groups of voters. Due to this they had an opportunity to put into 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 is enough for the party to have only three supporters in each of the first two groups. So it would be able to put into effect a decision with the help of only six votes "for" instead of nine, that would .be necessary in the case of general votes. 
    You are to write a program, which would determine according to the given partition of the electors the minimal number of supporters of the party, sufficient for putting into effect of any decision, with some distribution of those supporters among the groups.

    Input

    The input of this problem contains two lines. In the first line an only natural number K <= 101 — a quantity of groups — is written. In the second line there are 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 the number of groups also as the number of voters in each group is odd. You may also consider, that the population of the island does not exceeds 10001 persons.

    Output

    You should write an only natural number — a minimal quantity of supporters of the party, that can put into effect any decision.

    Sample Input

    3
    5 7 5
    

    Sample Output

    6

    Source

     1 //oimonster
     2 #include<cstdio>
     3 #include<cstdlib>
     4 #include<iostream>
     5 using namespace std;
     6 int a[10001];
     7 void qsort(int s[], int l, int r)
     8 {
     9     int t;
    10     int i = l, j = r, x = s[(i+j)/2];
    11     do
    12     {
    13         while(x>s[i]) 
    14             i++; 
    15         while(x<s[j])
    16             j--; 
    17         if(i <= j){
    18             t=s[i];
    19             s[i]=s[j];
    20             s[j]=t;
    21             i++;
    22             j--;
    23         }
    24     }while (i<j);
    25     if (l<j)
    26        qsort(s,l,j);
    27     if (i<r)
    28        qsort(s,i,r);
    29 }
    30 int main(){
    31     int i,j,n;
    32     scanf("%d",&n);
    33     for(i=1;i<=n;i++){
    34         scanf("%d",&a[i]);
    35     }
    36     qsort(a,1,n);
    37     int ans=0;
    38     for(i=1;i<=(n+1)/2;i++){
    39         ans+=(a[i]+1)/2;
    40     }
    41     printf("%d
    ",ans);
    42     return 0;
    43 }
    View Code
  • 相关阅读:
    Java 8实战之读书笔记五:超越Java 8
    Quartz的简单使用
    Quartz实现数据库动态配置定时任务
    Java解析Groovy和Shell的代码
    Spring学习笔记(3)——快速入门
    linux的防火墙端口配置
    气泡提示 纯CSS
    解决LINUX下SQLPLUS时上下左右键乱码问题
    redhat Enterprise Linux 6 VNC安装
    使用mount命令挂载CDROM
  • 原文地址:https://www.cnblogs.com/oimonster/p/4349125.html
Copyright © 2011-2022 走看看