Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n, m, fivecnt1 = 0, fivecnt2 = 0, fivecnt = 0;
- cin >> n;
- for (int i = 0; i < n; i++){
- cin >> m;
- if (m == 5) fivecnt1++;//сколько пойдёт на сдачу
- else fivecnt2 = m / 5 - 1;//сколько необходимо, чтобы выдать сдачу
- if (fivecnt2 - fivecnt1 > 0) fivecnt += fivecnt2 - fivecnt1;//разница между необходимым и имеемым
- fivecnt2 = 0;
- }
- if (fivecnt > 0) cout << fivecnt;
- else cout << 0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement