結果
| 問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-12-02 17:02:25 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 38 ms / 2,000 ms | 
| コード長 | 614 bytes | 
| コンパイル時間 | 1,543 ms | 
| コンパイル使用メモリ | 168,144 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-14 06:02:23 | 
| 合計ジャッジ時間 | 3,973 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 58 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  string s;cin >> s;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int q;cin >> q;
  for(int x=0;x<q;x++){
    int k;cin >> k;
    int r=0;
    int ans=0;
    int sum=0;
    int cnt=0;
    for(int l=0;l<n;l++){
      while(r<n&&sum+a[r]<=k){
        sum+=a[r];
        if(s[r]=='E'){
          cnt++;
        }
        r++;
      }
      ans=max(ans,cnt);
      if(l==r){
        r++;
      }
      else{
        sum-=a[l];
        if(s[l]=='E'){
          cnt--;
        }
      }
    }
    cout << ans << endl;
  }
}
            
            
            
        