fork download
  1. #include<iostream>
  2. #include<string>
  3. #include<iomanip>
  4. #include<algorithm>
  5. #include<cmath>
  6. #include<vector>
  7. #include<math.h>
  8. #include<set>
  9. #include<map>
  10. using namespace std;
  11. void mansour()
  12. {
  13. std::ios_base::sync_with_stdio(0);
  14. cin.tie(NULL);
  15. cout.tie(NULL);
  16. }
  17. /*int gcd(int a, int b)
  18. {
  19. if (!b)return a;
  20. return gcd(b, a%b);
  21. }
  22. void binary (long long n)
  23. {
  24. if(n==0)
  25. {
  26. cout <<"0\n";
  27. return;
  28. }
  29. string s="";
  30. while(n)
  31. {
  32. s+=char(n%2+'0');
  33. n/=2;
  34. }
  35. reverse(s.begin(),s.end());
  36. cout <<s<<"\n";
  37. }*/
  38. /*
  39. long long pask[35][35];
  40. void pas(int n)
  41. {
  42. for(int i=0;i<=n;i++)
  43. {
  44. for(int j=0;j<=i;j++)
  45. {
  46. if(j==0 || j==i)
  47. pask[i][j]=1;
  48. else
  49. pask[i][j]=pask[i-1][j]+pask[i-1][j-1];
  50. if(1)
  51. cout <<pask[i][j]<<" ";
  52. }
  53. cout <<"\n";
  54. }
  55. }
  56. */
  57. /*void fac(long long n,long long x)
  58. {
  59. long long f=n,ans=0;
  60. for(int i=2;i<x;i+=2)
  61. {
  62. f=n;
  63. for(int j=1;j<i;j++)
  64. f*=f;
  65. ans+=f;
  66. f=n;
  67. //cout <<f<<"\n";
  68. //cout <<ans<<"\n";
  69. }
  70. cout <<ans<<"\n";
  71. }*/
  72. int x[10];
  73. int main()
  74. {
  75. mansour();
  76. /*The First*/
  77. long long n,c,a[101];
  78. double av,s,sum=0;
  79. cin>>n;
  80. sum=0;
  81. for(int i=0;i<n;i++)
  82. {
  83. cin>>a[i];
  84. sum+=a[i];
  85. //cout <<sum<<" ";
  86. x[a[i]]++;
  87. }
  88. av=sum/n;
  89. //cout <<av<<"\n";
  90. if(av>=4.5)
  91. cout <<"0\n";
  92. else
  93. {
  94. int sum2=0;
  95. c=0;
  96. s=(4.5*n)-sum;
  97. for(int i=2;i<6;i++)
  98. {
  99. while(x[i])
  100. {
  101. c++;
  102. sum2+=(5-i);
  103. if(sum2>=s)
  104. {
  105.  
  106. break;
  107. }
  108. else
  109. {
  110. // c++;
  111. x[i]--;
  112. }
  113. }
  114. }
  115. cout <<c<<"\n";
  116. }
  117. }
Runtime error #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
Standard output is empty