Codeforces Round #491 (Div. 2) B. Getting an A
B. Getting an A
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.5 would be rounded up to 5 (as in example 3), but 4.4 would be rounded down to 4.
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 5 (maybe even the dreaded 2). 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 5 for the course. Of course, Vasya will get 5 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 n — the number of Vasya’s grades (1≤n≤100).
The second line contains n integers from 2 to 5 — 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 5.
Examples
input
3
4 4 4
output
2
input
4
5 4 5 5
output
0
input
4
5 3 3 5
output
1
My Answer Code:
/*
Author:Albert Tesla Wizard
Time:2020/11/11
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,sum=0,ans=0;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
while(sum*1.0/n<4.5)
{
ans++;
sort(a.begin(),a.end());
a[0]=5;
sum=0;
for(int i=0;i<n;i++)sum+=a[i];
}
cout<<ans<<'\n';
return 0;
}
相關文章
- Codeforces Round #242 (Div. 2) B. Megacity
- Codeforces Round #249 (Div. 2) B. Pasha Maximizes
- Codeforces Round #252 (Div. 2) B. Valera and FruitsUI
- Codeforces Round #246 (Div. 2) B. Football Kit
- Codeforces Round #244 (Div. 2) B. Prison Transfer
- Codeforces Round #228 (Div. 2) B. Fox and CrossROS
- Codeforces Round #215 (Div. 2) B. Sereja and Suffixes
- Codeforces Round #243 (Div. 2) B. Sereja and Mirroring
- Codeforces Round #196 (Div. 2) B. Routine Problem
- Codeforces Round #251 (Div. 2) B. Devu, the Dumb Guydev
- Codeforces Round #209 (Div. 2) B. Permutation
- Codeforces Round #676 (Div. 2) B. Putting Bricks in the Wall
- Codeforces Round #213 (Div. 2) B. The Fibonacci Segment
- Codeforces Round #248 (Div. 2) B. Kuriyama Mirai's StonesAI
- Codeforces Round #216 (Div. 2) B. Valera and Contest
- Codeforces Round #235 (Div. 2) B. Sereja and Contests
- Codeforces Round #233 (Div. 2) B. Red and Blue Balls
- Codeforces Round #192 (Div. 2) B. Road ConstructionStruct
- Codeforces Round #407 (Div. 1) B. Weird journey
- Codeforces Round 928 (Div. 4) B. Vlad and Shapes
- Codeforces Round #639 (Div. 2)
- Codeforces Round #541 (Div. 2)
- Codeforces Round #682 (Div. 2)
- Codeforces Round #678 (Div. 2)
- Codeforces Round #747 (Div. 2)
- Codeforces Round #673 (Div. 2)
- Codeforces Round #672 (Div. 2)
- Codeforces Round #448 (Div. 2) A
- Codeforces Round #217 (Div. 2)
- Codeforces Round #256 (Div. 2)
- Codeforces Round #259 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #258 (Div. 2)
- Codeforces Round #171 (Div. 2)
- Codeforces Round #173 (Div. 2)
- Codeforces Round 932 (Div. 2)
- Codeforces Round 934 (Div. 2)
- Codeforces Round 940 (Div. 2)