CF991B

B. Getting an A

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Translator’s note: in Russia’s most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.

The term is coming to an end and students start thinking about their grades. Today, a professor told his students that the grades for his course would be given out automatically — he would calculate the simple average (arithmetic mean) of all grades given out for lab works this term and round to the nearest integer. The rounding would be done in favour of the student — 4.54.5 would be rounded up to 55 (as in example 3), but 4.44.4 would be rounded down to 44.

This does not bode well for Vasya who didn’t think those lab works would influence anything, so he may receive a grade worse than 55 (maybe even the dreaded 22). However, the professor allowed him to redo some of his works of Vasya’s choosing to increase his average grade. Vasya wants to redo as as few lab works as possible in order to get 55 for the course. Of course, Vasya will get 55 for the lab works he chooses to redo.

Help Vasya — calculate the minimum amount of lab works Vasya has to redo.

Input

The first line contains a single integer nn — the number of Vasya’s grades (1≤n≤1001≤n≤100).

The second line contains nn integers from 22 to 55 — Vasya’s grades for his lab works.

Output

Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a 55.

Examples

input

Copy

3
4 4 4

output

Copy

2

input

Copy

4
5 4 5 5

output

Copy

0

input

Copy

4
5 3 3 5

output

Copy

1

Note

In the first sample, it is enough to redo two lab works to make two 44s into 55s.

In the second sample, Vasya’s average is already 4.754.75 so he doesn’t have to redo anything to get a 55.

In the second sample Vasya has to redo one lab work to get rid of one of the 33s, that will make the average exactly 4.54.5 so the final grade would be 55.


这题重要的关注点在于要注意如何四舍五入和理解题意。相当于是把以前没到5的项目给做到5,然后每次更新到5的时候都要更新平均值

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctype.h>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <sstream>
#define ll long long
#define re return

using namespace std;

bool cmp(int a, int b){
    return a > b;
}

int main(){
    int n;
    int a[1000];
    int summ = 0;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        summ += a[i];
    }

    int av = ((double)(1.0 * summ / (n * 1.0)) + 0.5);
    sort(a + 1, a + 1 + n);
    int i = 1;
    while(av < 5){
        if(a[i] == 5)
            break;
        summ = summ - a[i] + 5;
        // cout << summ << endl;
        av = ((double)(1.0 * summ / (n * 1.0)) + 0.5);
        // cout << av << endl;
        i++;
        ans++;
    }
    cout << ans;
    re 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值