题目超级水,但题目意思不好理解(英语太差。。。),排个序,然后答案就出来了。
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3136 | Accepted: 2311 |
Description
Input
Output
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\n",ans); 42 return 0; 43 }
原文:http://www.cnblogs.com/oimonster/p/4349125.html