码迷,mamicode.com
首页 > 其他好文 > 详细

杭电 2803 The MAX(sort)

时间:2016-07-20 21:05:07      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

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
 
 1 #include<cstdio>
 2 #include<algorithm>
 3 using namespace std;
 4 int a[100000];
 5 int main()
 6 {
 7     __int64 n,j;
 8     while(scanf("%I64d",&n)&&n)
 9     {
10         for(__int64 i=0;i<n;i++)
11         {
12             scanf("%d",&a[i]);
13         }
14         sort(a,a+n);
15         j=a[n-1]*(2010-n);
16         for(__int64 i=1;i < n; i++)
17         j=j+a[n-1-i];
18         printf("%I64d\n",j);
19     }
20 }

 

 

杭电 2803 The MAX(sort)

标签:

原文地址:http://www.cnblogs.com/yexiaozi/p/5689615.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!