心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0
This problem is too easy!
Here is my code:
#include<iostream>
#define maxn 107
using namespace std;
void Qsort(long *a,long l,long r)
{
    
long i=l,j=r,mid=a[(l+r)/2];
    
do{
        
while(a[i]<mid) i++;
        
while(a[j]>mid) j--;
        
if(i<=j)
        {
            
long t=a[i];a[i]=a[j];a[j]=t;
            i
++;j--;
        }
    }
while(i<=j);
    
if(l<j) Qsort(a,l,j);
    
if(i<r) Qsort(a,i,r);
}
int main()
{
    
/*
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    //
*/
    
long k,r[maxn],ans;
    cin
>>k;
    
for(long i=1;i<=k;i++)
        cin
>>r[i];
    
//  Input
    Qsort(r,1,k);
    
//  Qsort
    ans=0;
    
for(long i=1;i<=k/2+1;i++)
        ans
+=(r[i]/2+1);
    cout
<<ans<<endl;
return 0;
}


posted on 2010-09-25 21:05 lee1r 阅读(151) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:基础/模拟

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理