-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Cinema_Line.cpp
More file actions
42 lines (42 loc) · 951 Bytes
/
A_Cinema_Line.cpp
File metadata and controls
42 lines (42 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n; cin >> n;
vector<int> v(n);
map<int, int> mp;
for(auto &i : v) cin >> i;
for(int i = 0; i < n; i++){
if(v[i] == 25){
mp[v[i]]++;
}
else if(v[i] == 50){
if(mp[25] == 0){
cout << "NO" << endl;
return 0;
}
mp[25]--;
mp[50]++;
}
else if(v[i] == 100){
if(mp[25] == 0){
cout << "NO" << endl;
return 0;
}
if(mp[50] >= 1 and mp[25] >= 1){
mp[50]--, mp[25]--;
mp[100]++;
}
else if(mp[25] >= 3){
mp[25] -= 3;
mp[100]++;
}
else{
cout << "NO" << endl;
return 0;
}
}
}
cout << "YES" << endl;
return 0;
}