| 25 | #define ll long long int |
| 26 | |
| 27 | bool solve() |
| 28 | { |
| 29 | ll n; |
| 30 | cin >> n; |
| 31 | |
| 32 | ll five = 0; |
| 33 | ll ten = 0; |
| 34 | ll x; |
| 35 | |
| 36 | bool ans = true; |
| 37 | |
| 38 | for (int i = 0; i < n; ++i) |
| 39 | { |
| 40 | cin >> x; |
| 41 | if (x == 5) |
| 42 | { |
| 43 | five++; |
| 44 | } |
| 45 | else if (x == 10) |
| 46 | { |
| 47 | if (five <= 0) |
| 48 | ans = false; |
| 49 | five--; |
| 50 | ten++; |
| 51 | } |
| 52 | else if (x == 15) |
| 53 | { |
| 54 | if (ten > 0) |
| 55 | ten--; |
| 56 | else if (five >= 2) |
| 57 | five -= 2; |
| 58 | else |
| 59 | { |
| 60 | ans = false; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return ans; |
| 66 | } |
| 67 | |
| 68 | int main() |
| 69 | { |