Advertisement
Glebzok

Tinkoff FrontEnd A

Feb 15th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int n, m, fivecnt1 = 0, fivecnt2 = 0, fivecnt = 0;
  6.     cin >> n;
  7.     for (int i = 0; i < n; i++){
  8.         cin >> m;
  9.         if (m == 5) fivecnt1++;//сколько пойдёт на сдачу
  10.         else fivecnt2 = m / 5 - 1;//сколько необходимо, чтобы выдать сдачу
  11.         if (fivecnt2 - fivecnt1 > 0) fivecnt += fivecnt2 - fivecnt1;//разница между необходимым и имеемым
  12.         fivecnt2 = 0;
  13.     }
  14.     if (fivecnt > 0) cout << fivecnt;
  15.     else cout << 0;
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement