CF991B Getting an A
3583 단어 욕심
Getting an A
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 4.5 would be rounded up to 5 5 (as in example 3), but 4.4 4.4 would be rounded down to 4 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 5 (maybe even the dreaded 2 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 5 for the course. Of course, Vasya will get 5 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 n — the number of Vasya’s grades (1≤n≤100) ( 1 ≤ n ≤ 100 ) .
The second line contains n n integers from 2to5 2 t o 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 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
Note
In the first sample, it is enough to redo two lab works to make two 4 4 s into 5 5 s.
In the second sample, Vasya’s average is already 4.75 4.75 so he doesn’t have to redo anything to get a 5 5 .
In the second sample Vasya has to redo one lab work to get rid of one of the 3 3 s, that will make the average exactly 4.5 4.5 so the final grade would be 5 5 .
해제
작은 것 부터 큰 것 까지 순 서 를 한 번 배열 하 다.
코드
#include
using namespace std;
int a[105],sum,n;
void in(){scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",&a[i]),sum+=a[i];}
void ac()
{
sort(a+1,a+1+n);
for(int i=0;i<=n;++i,sum=sum-a[i]+5)
if(sum>=4.5*n)printf("%d",i),exit(0);
}
int main(){in();ac();}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
HPU - ACM 여름 훈련 2 주차 14 급 개인전: Problem D [욕심]Problem D Problem Description 그 러 고 보 니 해동 그룹 이 안팎 으로 어려움 을 겪 고 있 고 회사 의 원로 도 XHD 부부 만 남 았 다 고 한다.분명히 여러 해 동안 싸 운 상인 으로서...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.