Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> bills(n);
- for (int i = 0; i < n; ++i) {
- cin >> bills[i];
- }
- int change_25 = 0, change_50 = 0;
- for (int i = 0; i < n; ++i) {
- if (bills[i] == 25) {
- change_25++;
- }
- else if (bills[i] == 50) {
- if (change_25 > 0) {
- change_25--;
- change_50++;
- } else {
- cout << "NO" << endl;
- return 0;
- }
- }
- else {
- if (change_50 > 0 && change_25 > 0) {
- change_50--;
- change_25--;
- } else if (change_25 >= 3) {
- change_25 -= 3;
- } else {
- cout << "NO" << endl;
- return 0;
- }
- }
- }
- cout << "YES" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement