Advertisement
Guest User

491B

a guest
Jun 23rd, 2018
1,321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool check(int sum, int n) {
  6.     // integer representation of sum / n >= 4.5
  7.     return sum * 10 >= n * 45;
  8. }
  9.  
  10. int main() {
  11.     vector<int> v;
  12.     int sum = 0;
  13.  
  14.     int n;
  15.     cin >> n;
  16.     for (int i = 0; i < n; i++) {
  17.         int x;
  18.         cin >> x;
  19.         v.push_back(x);
  20.         sum += x;
  21.     }
  22.  
  23.     sort(v.begin(), v.end());
  24.     int ans = 0;
  25.     while (!check(sum, n)) {
  26.         sum += 5 - v[ans];
  27.         ans++;
  28.     }
  29.  
  30.     cout << ans;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement