-
Notifications
You must be signed in to change notification settings - Fork 0
/
Getting An A.cpp
60 lines (54 loc) · 990 Bytes
/
Getting An A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<bits/stdc++.h>
using namespace std;
int myf(int a,int b)
{
return a>b;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int n,sum=0,cnt=0;
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
{
cin>>arr[i];
sum+=arr[i];
}
sort(arr,arr+n);
double val=0;
val=1.0*sum/n;
if(val>=4.5)
{
cout<<0<<endl;
return 0;
}
else
{
for(int i=0; i<n; i++)
{
if(arr[i]<5)
{
int a=5-arr[i];
arr[i]+=a;
cnt++;
}
sum=0,val=0;
for(int j=0; j<n; j++)
{
sum+=arr[j];
}
val=1.0*sum/n;
// cout<<val<<" ";
if(val>=4.5)
{
cout<<cnt<<endl;
return 0;
//break;
}
}
}
// cout<<cnt<<endl;
return 0;
}