# HDU2535 vote

Vote

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3391    Accepted Submission(s): 1829

Problem Description

Input

Output

Sample Input
3
5 7 5
0

Sample Output
6

#include<stdio.h>
#include<iostream>
using namespace std;
/*int paixu(int *a,int n)
{   int i,j,temp;
for(i=0;i<n-1;i++)
for(j=0;j<n-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}

}
qqqqqqq
} */
int main()
{
int n,i,j,m,flag,temp;
int a[105];
while(cin>>n&&n)
{   int sum=0;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
for(j=0;j<n-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;

}

}
/* if(n%2==0)
{  sum=0;
//if(a[i]%2==0)
for(i=0;i<n/2;i++)
{
if(a[i]%2==0)
sum+=a[i]/2;
else
sum+=a[i]/2+1;
//sum+=a[i]/2;
}

}
if(n%2!=0)
{  sum=0;
for(i=0;i<n/2+1;i++)
{
if(a[i]%2==0)
sum+=a[i]/2;
else
sum+=a[i]/2+1;
//sum+=a[i]/2;

}
}
*/
for(i = 0; i<n/2+1; i++)//算出最小的前几个的票民数即所求
sum = a[i]/2+1 + sum;
cout<<sum<<endl;
}

return 0;
}

posted @ 2014-04-20 17:18 盒子先生★ 阅读(...) 评论(...) 编辑 收藏