結果
| 問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム | 
| コンテスト | |
| ユーザー |  toririm_ | 
| 提出日時 | 2019-11-29 23:15:12 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 72 ms / 2,000 ms | 
| コード長 | 740 bytes | 
| コンパイル時間 | 1,260 ms | 
| コンパイル使用メモリ | 160,932 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-14 05:53:44 | 
| 合計ジャッジ時間 | 4,337 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 58 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long
signed main(){
    string s;
    int n;cin>>n>>s;
    int a[n+1];
    int w[n+1];
    w[0]=0;
    rep(i,n){
        w[i+1]=w[i]+(s[i]=='E');
    }
    a[0]=0;
    rep(i,n){
        int r;cin>>r;
        a[i+1]=a[i]+r;
    }
    int q;cin>>q;
    rep(i,q){
        int k;
        cin>>k;
        int ans=0;
        rep(i,n){
            auto j=upper_bound(a+i,a+n+1,k+a[i]);
            int it=j-a-1;
            //printf("s:%lld it:%lld si:%lld\n",i,w[it],w[i]);
            ans=max(ans,w[it]-w[i]);
        }
        cout<<ans<<endl;
        //cout<<endl;
    }
}
            
            
            
        