Ural 1025 Democracy in danger

Ural 1025 Democracy in danger
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 ;
}


你可能感兴趣的:(Ural 1025 Democracy in danger)