提交时间:2024-05-19 16:29:39
运行 ID: 47683
#include<bits/stdc++.h> using namespace std; int main() { int a,b[110],i,j,k,q; while(scanf("%d",&a),a!=0) { memset(b,0,sizeof(b)); for(i=0;i<a;i++) scanf("%d",&b[i]); sort(b,b+a); q=0; for(i=0;i<a/2+1;i++) q+=b[i]/2+1; printf("%d\n",q); } return 0; } if(!n) break; sum = 0; for(int i = 1; i <= n; i ++) { scanf("%d", &num[i]); a[i] = num[i] / 2; a[i] ++; } sort(a + 1, a + 1 + N); for(int i = 1; i <= n / 2 + 1; i ++) sum += a[i]; printf("%d\n", sum); } return 0; }