-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathchef and Icecream.cpp
50 lines (47 loc) · 1.2 KB
/
chef and Icecream.cpp
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
43
44
45
46
47
48
49
50
//
// COMPETITIVE PROGRAMMING .cpp
//
// Created by Prince Kumar on 15/06/2020.
// Copyright © 2020 Prince Kumar. All rights reserved.
//
// ---** COMPETITIVE PROGRAMMING in C++ **---
// ---** PRACTICE CODING SKILLS **---
// ---** CHEF AND ICECREAM **---
#include <iostream>
using namespace std;
int main(){
int T; cin>>T;
while(T--){
int n; cin>>n;
int a[3]= {0,0,0}; // 5 10 15
int check=0;
for(int i=0;i<n;i++){
int x; cin>>x;
if(x==5){
a[0]+=1;
}else if(x==10){
if(a[0]>=1){
a[1]+=1;
a[0]-=1;
}else{
check++;
}
}else{
if(a[1]>=1){
a[2]+=1;
a[1]-=1;
}else if(a[0]>=2){
a[2]+=1;
a[0]-=2;
}else{
check++;
}
}
}
if(check==0){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
}