Hangzhou Electric 2803 The MAX (sort)

Source: Internet
Author: User

descriptiongiving N integers, V1, V2,,,, Vn, you should find the biggest value of F.
Inputeach 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 is processed. Outputfor each test case, output the biggest value of F can find on a line. Sample Input21 Sample Output4017
1#include <cstdio>2#include <algorithm>3 using namespacestd;4 inta[100000];5 intMain ()6 {7 __int64 n,j;8      while(SCANF ("%i64d", &n) &&N)9     {Ten          for(__int64 i=0; i<n;i++) One         { Ascanf"%d",&a[i]); -         } -Sort (a,a+n); thej=a[n-1]*( .-n); -          for(__int64 i=1; i < n; i++) -j=j+a[n-1-i]; -printf"%i64d\n", j); +     } -}

Hangzhou Electric 2803 The MAX (sort)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.