結果
| 問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム | 
| コンテスト | |
| ユーザー |  leaf_1415 | 
| 提出日時 | 2019-11-29 22:00:06 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 30 ms / 2,000 ms | 
| コード長 | 714 bytes | 
| コンパイル時間 | 668 ms | 
| コンパイル使用メモリ | 60,452 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-14 05:42:31 | 
| 合計ジャッジ時間 | 2,776 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 58 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#define llint long long
#define inf 1e18
using namespace std;
llint n, Q;
llint a[2005];
string s;
int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	for(int i = 1; i <= n; i++) cin >> a[i];
	a[n+1] = inf;
	
	s = "#" + s;
	
	cin >> Q;
	llint k;
	for(int q = 0; q < Q; q++){
		cin >> k;
		llint r = 0, sum = 0, cnt = 0, ans = 0;
		for(int l = 1; l <= n; l++){
			while(sum <= k){
				sum += a[r+1];
				r++;
				if(s[r] == 'E') cnt++;
			}
			//cout << l << " " << r << endl;
			llint tmp = cnt;
			if(s[r] == 'E') tmp--;
			ans = max(ans, tmp);
			if(s[l] == 'E') cnt--;
			sum -= a[l];
		}
		cout << ans << endl;
	}
	
	return 0;
}
            
            
            
        