您的位置:首页 > 其它

hdoj2803The MAX

2016-01-29 09:11 169 查看


The MAX

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2176    Accepted Submission(s): 953


Problem Description

Giving N integers, V1, V2,,,,Vn, you should find the biggest value of F.



 

Input

Each test case contains a single integer N (1<=N<=100). The next line contains N integers, meaning the value of V1, V2....Vn.(1<= Vi <=10^8).The input is terminated by a set starting with N = 0. This set should not be processed.

 

Output

For each test case, output the biggest value of F you can find on a line.

 

Sample Input

2
1 2
0

 

Sample Output

4017

 

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
using namespace std;
const int maxn=10010;
int main()
{
int i,j;
long long sum,maxm,k,n;
while(scanf("%lld",&n),n){
sum=0;maxm=0;
for(i=0;i<n;++i){
scanf("%lld",&k);sum+=k;
maxm=max(maxm,k);
}
sum-=maxm;
printf("%lld\n",sum+maxm*(2009-n+1));
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hdoj2803The MAX