結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー toto6114
提出日時 2019-11-30 15:45:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 93,872 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 06:01:13
合計ジャッジ時間 2,856 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[2005]={},ene[2005]={};
  string s;
  cin >> n >> s;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=1; i<=n; i++) {
    ene[i]=ene[i-1];
    if(s[i-1]=='E') {
      ene[i]++;
    }
  }
  ll q,b[2005]={};
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> b[i];
  }
  for(int i=0; i<q; i++) {
    ll ans=0,r=0,cnt=0;
    for(int l=0; l<n; l++) {
      while(r<n&&cnt+a[r]<=b[i]) {
        cnt+=a[r];
        r++;
      }
      ans=max(ans,ene[r]-ene[l]);
      if(r==l) {
        r++;
      }
      else {
        cnt-=a[l];
      }
    }
    cout << ans << endl;
  }
}
0