B. Getting an A(水题)

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 (1n1001≤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


题意:给出n,和n个数 ai (2<=ai<=5),你可以将其中任意一个不为5的数改成5.求出这些数的平均值(四舍五入),问,最少改动几个数,可以使得平均值为5.

思路:从最小的ai开始改动就可以了,数据不大。注意一下精度

#include "iostream"
#include "algorithm"
#include "cmath"
using  namespace std;
#define esp 1e-8
int a[105];
int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=0;i<n;i++) {cin>>a[i];sum+=a[i];}
    sort(a,a+n);
    double ans=sum*1.0/n;
    if(ans-4.5>esp||fabs(ans-4.5)<esp) cout<<"0"<<endl;
    else{
        int cnt=0;
        for(int i=0;i<n;i++){
            sum+=5-a[i];
            ans=sum*1.0/n;
            cnt++;
            if(ans-4.5>esp||fabs(ans-4.5)<esp) break;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AN5401 初步使用 CSEC 安全模块 AN5401 是一款用于安全通信的 CSEC(Communication Security)模块,可以在嵌入式系统中实现加密、解密、认证和安全通信等功能。下面是初步使用该模块的步骤: 1. 硬件连接:首先,将 AN5401 模块与目标嵌入式系统进行连接。确保电源、地线和通信线的连接正确无误。接下来,可以根据具体的需求选择是否连接外部加密芯片或安全存储器。 2. 引入库文件:将 AN5401 的驱动库文件引入到开发环境中。这些库文件包括 CSEC 的功能接口和相关的加密算法库。通过这些库文件,可以在开发时轻松调用 AN5401 的各项功能。 3. 初始化配置:在软件层面对 AN5401 进行初始化配置。这包括设置加密算法、密钥长度、认证方式等参数。通过正确的初始化配置,可以确保 AN5401 模块的安全功能得到充分发挥。 4. 调用功能接口:根据需求,在程序中调用 AN5401 提供的各种功能接口,如加密数据、解密数据、进行认证等。同时,也要注意错误处理和异常情况的处理,以确保系统的稳定性和安全性。 5. 测试验证:在完成初始化配置和功能调用后,需要进行一系列的测试验证工作,确保 AN5401 模块在实际应用中能够正常运行并达到预期的安全效果。 通过以上步骤,您可以初步使用 AN5401 CSEC 安全模块,并在嵌入式系统中实现加密、解密、认证和安全通信等功能。如果在使用过程中遇到问题,建议查阅 AN5401 的技术手册或者向厂家寻求帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值