結果
| 問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム | 
| コンテスト | |
| ユーザー |  square1001 | 
| 提出日時 | 2020-01-21 22:58:19 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 10 ms / 2,000 ms | 
| コード長 | 628 bytes | 
| コンパイル時間 | 675 ms | 
| コンパイル使用メモリ | 72,668 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-06 11:25:02 | 
| 合計ジャッジ時間 | 2,213 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 58 | 
ソースコード
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N; string S;
	cin >> N >> S;
	vector<long long> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<long long> opt(N + 1, 1LL << 62);
	opt[0] = 0;
	for(int i = 0; i < N; ++i) {
		long long sum = 0; int cnt = 0;
		for(int j = i; j < N; ++j) {
			sum += A[j];
			if(S[j] == 'E') ++cnt;
			opt[cnt] = min(opt[cnt], sum);
		}
	}
	int Q;
	cin >> Q;
	while(Q--) {
		long long x;
		cin >> x;
		int ans = 0;
		for(int i = 0; i <= N; ++i) {
			if(opt[i] <= x) ans = i;
		}
		cout << ans << endl;
	}
	return 0;
}
            
            
            
        