結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー misora192misora192
提出日時 2020-04-25 16:47:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 171,392 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 22:37:56
合計ジャッジ時間 6,940 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,248 KB
testcase_01 AC 32 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 48 ms
5,376 KB
testcase_04 AC 51 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 82 ms
5,376 KB
testcase_07 AC 75 ms
5,376 KB
testcase_08 AC 195 ms
5,376 KB
testcase_09 AC 110 ms
5,376 KB
testcase_10 AC 133 ms
5,376 KB
testcase_11 AC 169 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 53 ms
5,376 KB
testcase_18 AC 33 ms
5,376 KB
testcase_19 AC 85 ms
5,376 KB
testcase_20 AC 64 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 4 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 79 ms
5,376 KB
testcase_34 AC 134 ms
5,376 KB
testcase_35 AC 125 ms
5,376 KB
testcase_36 AC 29 ms
5,376 KB
testcase_37 AC 79 ms
5,376 KB
testcase_38 AC 76 ms
5,376 KB
testcase_39 AC 146 ms
5,376 KB
testcase_40 AC 167 ms
5,376 KB
testcase_41 AC 158 ms
5,376 KB
testcase_42 AC 123 ms
5,376 KB
testcase_43 AC 164 ms
5,376 KB
testcase_44 AC 46 ms
5,376 KB
testcase_45 AC 167 ms
5,376 KB
testcase_46 AC 12 ms
5,376 KB
testcase_47 AC 61 ms
5,376 KB
testcase_48 AC 46 ms
5,376 KB
testcase_49 AC 55 ms
5,376 KB
testcase_50 AC 68 ms
5,376 KB
testcase_51 AC 85 ms
5,376 KB
testcase_52 AC 85 ms
5,376 KB
testcase_53 AC 146 ms
5,376 KB
testcase_54 AC 30 ms
5,376 KB
testcase_55 AC 5 ms
5,376 KB
testcase_56 AC 110 ms
5,376 KB
testcase_57 AC 71 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int n;
string s;
vector<ll> a;

vector<ll> b;
vector<int> sco;

int solve(ll k){
	int ans = 0;
	rep(i, n){
		auto itr = upper_bound(b.begin(), b.end(), b[i] + k);
		itr--;
		int p = itr - b.begin();

		ans = max(ans, sco[p] - sco[i]);
	}

	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;
	cin >> s;

	a.resize(n);
	rep(i, n) cin >> a[i];

	b.resize(n+1, 0);
	rep(i, n) b[i+1] = b[i] + a[i];

	sco.resize(n+1, 0);
	rep(i, n) sco[i+1] = sco[i] + (s[i] == 'E' ? 1 : 0);

	int q;
	cin >> q;

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

	rep(i, q) cout << solve(k[i]) << "\n";
}
0