結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー wunderkammer2wunderkammer2
提出日時 2019-12-05 23:47:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 85,852 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 06:44:25
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,348 KB
testcase_01 AC 8 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 7 ms
4,348 KB
testcase_04 AC 7 ms
4,356 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 15 ms
4,356 KB
testcase_07 AC 13 ms
4,348 KB
testcase_08 AC 28 ms
4,352 KB
testcase_09 AC 18 ms
4,348 KB
testcase_10 AC 21 ms
4,348 KB
testcase_11 AC 30 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 19 ms
4,352 KB
testcase_18 AC 8 ms
4,348 KB
testcase_19 AC 17 ms
4,352 KB
testcase_20 AC 13 ms
4,348 KB
testcase_21 AC 4 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,352 KB
testcase_33 AC 14 ms
4,352 KB
testcase_34 AC 26 ms
4,348 KB
testcase_35 AC 23 ms
4,352 KB
testcase_36 AC 7 ms
4,348 KB
testcase_37 AC 15 ms
4,348 KB
testcase_38 AC 17 ms
4,348 KB
testcase_39 AC 28 ms
4,348 KB
testcase_40 AC 29 ms
4,348 KB
testcase_41 AC 29 ms
4,352 KB
testcase_42 AC 23 ms
4,348 KB
testcase_43 AC 31 ms
4,352 KB
testcase_44 AC 12 ms
4,348 KB
testcase_45 AC 30 ms
4,348 KB
testcase_46 AC 5 ms
4,356 KB
testcase_47 AC 14 ms
4,348 KB
testcase_48 AC 10 ms
4,352 KB
testcase_49 AC 12 ms
4,352 KB
testcase_50 AC 15 ms
4,348 KB
testcase_51 AC 17 ms
4,348 KB
testcase_52 AC 17 ms
4,352 KB
testcase_53 AC 27 ms
4,352 KB
testcase_54 AC 7 ms
4,348 KB
testcase_55 AC 3 ms
4,352 KB
testcase_56 AC 22 ms
4,348 KB
testcase_57 AC 14 ms
4,348 KB
testcase_58 AC 1 ms
4,348 KB
testcase_59 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{	
	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<ll> as(n);
	rep(i, n) cin >> as[i];


	int q;
	cin >> q;

	vector<ll> ks(q);
	rep(i, q) cin >> ks[i];


	for (auto k : ks)
	{
		ll maxCount = 0;

		//倒せる敵の数の最大値を尺取り法で計算(範囲はleft<=i<=right)
		ll count = 0;
		ll power = k;
		int right = -1;

		rep(left, n)
		{
			//前回左端の結果を戻す
			if (left > 0)
			{
				power += as[left - 1];

				if(s[left - 1] == 'E')count--;				
			}
			
			while (right + 1 < n)
			{
				//威力が足りない場合は終了
				if (power < as[right + 1]) break;

				right++;

				//敵破壊数をカウントアップ
				if (s[right] == 'E') count++;

				//威力減衰
				power -= as[right];
			}

			//最大値更新
			maxCount = max(maxCount, count);
		}

		cout << maxCount << endl;
	}
	return 0;
}
0