#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; void solve(){ int n; cin>>n; string s; cin>>s; vectora(n); rep(i,n)cin>>a[i]; vectorene(n+1),hp(n+1); rep(i,n){ if(s[i]=='E')ene[i+1]=ene[i]+1; else ene[i+1]=ene[i]; } rep(i,n){ hp[i+1]=hp[i]+a[i]; } int q; cin>>q; ll k; while(q--){ cin>>k; ll maxv=0; rep(i,n){ int id=upper_bound(hp.begin()+i,hp.end(),k-hp[i])-hp.begin(); id--; ll num=ene[id]-ene[i]; chmax(maxv,num); } cout<