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;
}
相关文章推荐
- MySQL中的max()函数使用教程
- JavaScript使用Max函数返回两个数字中较大数的方法
- python获取一组数据里最大值max函数用法实例
- Python中max函数用法实例分析
- 《水晶石精粹:3ds max & ZBrush三维数字静帧艺术》
- mongodb max,distinct操作
- php中max()的一些理解和疑问
- Transformation language 方法 IN, MAX
- 关于3Ds MAX在freeze transform后无法使用飘带插件springmagic的解决过程
- [MySQL]学习笔记- 用户行为表中,查询每个人的一条最新行为(分组 排序 取时间最大的一条记录)
- MYSQL中的聚集函数
- HDU Max Sum Plus Plus
- HDU To The Max
- HDU Max Sum
- lua math 库
- 最大子数组问题
- 循环-14. 最大公约数和最小公倍数(15)
- java socket 数据长度 最大
- sql 删除重复数据
- 大数据:add