Life of the battery

Source: Internet
Author: User

Total time limit:
1000ms
Memory Limit:
65536kB
Describe

Little s new bought a handheld game console powered by two battery 5th batteries. In order to be able to play the game for a long time, he bought a lot of 5th batteries, the manufacturers of these batteries are different, the quality of the difference, so the service life is different, some can use 5 hours, some may only use 3 hours. Obviously if he had only two batteries and one could use 5 hours a 3 hours, then he could only play 3 hours of the game, there is a battery remaining power can not be used, but if he has more batteries, it will be more fully utilized them, such as he has three batteries can be used 3, 3, 5 hours, He can use two energy-saving 3-hour battery, use half an hour after the one to use 5 hours of battery, 2.5 hours after the rest of the battery to replace the battery (the battery can also be used for 2.5 hours), so that the total can use 5.5 hours, not a little wasted.

Now that you know the number of batteries and the amount of time the battery can be used, please find a way to make the use of the time as long as possible.

Input

The input contains multiple sets of data. Each set of data consists of two rows, the first line being an integer n (2≤ n ≤1000), the number of batteries, and the next line is n positive integers indicating when the battery can be used.

Output

Output a row for each set of data, indicating the time that the battery can be used, reserved to 1 digits after the decimal point.

Sample input
2
3 5
   3
3 3 5
Sample output
3.0
   5.5
In fact, I do not do this question, look at the sample side to guess the results of a ...
1#include <bits/stdc++.h>2 using namespacestd;3 intN;4 inta[ -];5 intsum[ -];6 intMain () {7      while(SCANF ("%d", &n)! =EOF) {8memset (SUM,0,sizeof(sum));9Memset (A,0,sizeof(a));Ten          for(intI=1; i<=n;i++){ Onescanf"%d",&a[i]); A         } -Sort (A +1, a+n+1); -          for(intI=1; i<=n;i++){ thesum[i]=sum[i-1]+A[i]; -         } -         if(sum[n-1]>A[n]) { -             DoubleAns= (Double) (Sum[n])/(Double)2; +printf"%.1lf\n", ans); -         } +         Else{ Aprintf"%.1lf\n",(Double) sum[n-1]);  at         } -     } -     return 0; -}

Life of the battery

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.