Chef and Icecream

https://www.codechef.com/JUNE20B/problems/CHFICRM

HERE IS MY CODE ITS GIVING WA IN SUBTASK 1 MY CODE IS #include<bits/stdc++.h>
using namespace std;

int main(){
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;++i){
cin>>a[i];
}
map<int ,int>mp;
bool flag =true;
for(int i=0;i<n;++i){
if(a[i]==5){
mp[5]++;
}
else if(a[i]==10&&mp[5]>0){
mp[5]–;
mp[10]++;

``````		}
else if(a[i]==15&&(mp[5]>1)||(mp[10]>0)	){
if(mp[10]==0){
mp[5]-=2;
mp[15]++;
}
else if(mp[5]<=1){
mp[10]--;
mp[15]++;
}
else {
mp[10]--;
mp[15]++;
}
}
else flag =false;
}
if(flag)cout<<"YES";
else cout<<"NO";
cout<<"\n";
``````

}
}

``````
else if(a[i]==15&&(mp[5]>1)||(mp[10]>0)	){
if(mp[10]==0){
mp[5]-=2;
mp[15]++;
}
else if(mp[5]<=1){
mp[10]--;
mp[15]++;
}
else {
mp[10]--;
mp[15]++;
}
}
// in above else if block you are doing mistakes
//1-first mistake is that you not implemented && and || condition
//if mp[10] is greater than zero you will enter in condtion but
//in first subtask input is only 5 and 10 means if input value
// a[i] is not
// equal to 10 but value of mp[10]>0 then you enter in this condition
// which is wrong
//2-second mistake is that you not implement condition for "NO"
//out put in this block also

``````

you can change your above code to below which is accepted
you have just need to change above block not need to change whole code

``````else if(a[i]==15 && (mp[5]>1|| mp[10]>0)){
if(mp[10]>0){
mp[10]--;
mp[15]++;
}
else if(mp[5]>1){
mp[5]-=2;
mp[15]++;
}
else {
flag=false;
}
}

``````

@anumber thank u very much appreciated ur work thank U