杭电 2803 The MAX(sort)
2024-09-30 13:37:09
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<algorithm>
using namespace std;
int a[];
int main()
{
__int64 n,j;
while(scanf("%I64d",&n)&&n)
{
for(__int64 i=;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
j=a[n-]*(-n);
for(__int64 i=;i < n; i++)
j=j+a[n--i];
printf("%I64d\n",j);
}
}
最新文章
- 信息安全-5:RSA算法详解(已编程实现)[原创]
- Activity系列讲解---三大基本状态与七大生命周期函数
- MySQL级联删除的问题
- android技巧(一):如何方便知晓当前Activity?如何管理应用中的Activity?如何最佳的启动一个Activity?
- centOS6.5安装SUN-jdk7
- Create,Insert
- Regsvr32注册ActiveX控件
- 通过WebBrowser获取网页验证码
- [iOS基础控件 - 6.10.1] PickerView 餐点搭配Demo
- 用Python复习离散数学(一)
- 【原生js】js动态添加dom,如何绑定事件
- Linux下安装Java(JDK8)
- 多线程之:MESI-CPU缓存一致性协议
- Python3获取拉勾网招聘信息
- Python基础之re模块(正则表达式)
- HTML(三)
- 初学者须知 常见的HTML5开发工具有哪些
- 解决ubuntu 16.04+ Qt 5.7.1无法输入中文的问题
- VIM简单配置(windows)
- linq group by / distinct
热门文章
- python安装教学
- Fastjson详解
- .NET CORE技术路线图
- 上帝造题的七分钟2/花神游历各国/GSS4 线段树维护区间开方 By cellur925
- HDU 5558 后缀数组
- _bzoj1192 [HNOI2006]鬼谷子的钱袋【水题】
- LoadRunner12学习之路(6-8)
- Stamps ans Envelope Sive UVA - 242
- ACboy needs your help HDU - 1712
- 贪心 Codeforces Round #109 (Div. 2) B. Combination