https://www.codechef.com/START16C/
Pass or Fail
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n,x,p;
cin>>n>>x>>p;
int r=x*3+((n-x)*-1);
if(r>=p) cout<<"PASS"<<endl;
else cout<<"FAIL"<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int x,y,a=0,b=0,c=0,ans=0;
cin>>x>>y;
string s;
cin>>s;
for(int i=0;i<s.length();i++){
if(s[i]=='0') a++;
else b++;
if(s[i]=='0') c=0;
else {c++; ans=max(ans,c);}
}
cout<<(x*b+y*ans)<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
string s;
cin>>s;
for(int i=0;i<n-1;i++){
if(s[i]=='L' and s[i+1]=='L'){
cout<<"YES"<<endl;goto outoftheloop;
}
else if(s[i]=='R' and s[i+1]=='R'){
cout<<"YES"<<endl;goto outoftheloop;
}
}
cout<<"NO"<<endl;outoftheloop:;
}
return 0;
}