 MEENAMATH - Editorial

Author: Ram Agrawal
Editorialist:Prathamesh Sogale

CAKEWALK-EASY

PREREQUISITES:

Character-Array/String + Basic maths

PROBLEM:

DBATU is commencing its summer examinations, all papers except math’s have been completed. Meena is very weak in math’s and to pass in math’s he should solve specific no of questions. He also wasted a lot of time by taking breaks in between.

Given a Character string S of length L containing a sequence of characters “Q”, “T”, and “B”, where “Q” denotes a question, “T” denotes time and “B” denotes the break. In every break, he wastes N∗T amount of time. He needs 2T amount of time to solve a question “Q”.
You need to determine if he can solve all the questions or not if solved print “YES”
else print “NO”.

QUICK EXPLANATION:

All the questions will be solved if time to solve all the questions is less than the time total time remaining after the time is wasted by the meena.
So

SOLUTIONS:

Setter's Solution
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin>>T;
while(T--){
int L,W,Q_count=0,A_count=0,W_count=0;
string Str;
cin>>L>>W;
cin>>Str;
for(int i=0;i<L;i++){
if(Str[i]=='Q'){
Q_count++;
}else if(Str[i]=='A'){
A_count++;
}else{
W_count++;
}
}
if(2*Q_count<=A_count-(W*W_count)){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
return 0;
}