fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int x[7],s=0,n,i,j,k=0;
  5. cin>>n;
  6. x[2]=x[3]=x[4]=x[5]=0;
  7. for(i=0;i<n;i++){
  8. cin>>j;
  9. x[j]++;
  10. s+=j;
  11. }
  12. if(s>=n*4.5){
  13. cout<<0;
  14. return 0;
  15. }
  16. else{
  17. while(x[2]!=0&&s<n*4.5){
  18. x[2]--;
  19. s+=3;
  20. k++;
  21. }
  22. while(x[3]!=0&&s<n*4.5){
  23. x[3]--;
  24. s+=2;
  25. k++;
  26. }
  27. while(x[4]!=0&&s<n*4.5){
  28. x[4]--;
  29. s+=1;
  30. k++;
  31. }
  32. }
  33. cout<<k;
  34. return 0;
  35. }
Success #stdin #stdout 0s 4536KB
stdin
4
5 3 3 5
stdout
1