結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー misora192
提出日時 2020-04-25 16:47:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 174,756 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 07:49:34
合計ジャッジ時間 6,955 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

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