結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2020-03-18 15:54:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 170,880 KB
実行使用メモリ 49,824 KB
最終ジャッジ日時 2023-08-20 20:04:30
合計ジャッジ時間 12,084 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,376 KB
testcase_01 AC 45 ms
7,480 KB
testcase_02 AC 10 ms
8,844 KB
testcase_03 AC 89 ms
14,488 KB
testcase_04 AC 129 ms
24,476 KB
testcase_05 AC 18 ms
13,784 KB
testcase_06 AC 156 ms
14,956 KB
testcase_07 AC 170 ms
18,160 KB
testcase_08 AC 469 ms
48,640 KB
testcase_09 AC 237 ms
28,452 KB
testcase_10 AC 282 ms
29,872 KB
testcase_11 AC 386 ms
42,712 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 274 ms
49,824 KB
testcase_18 AC 84 ms
28,812 KB
testcase_19 AC 147 ms
14,744 KB
testcase_20 AC 163 ms
38,536 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 11 ms
12,184 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,504 KB
testcase_33 AC 197 ms
43,472 KB
testcase_34 AC 301 ms
31,028 KB
testcase_35 AC 279 ms
33,728 KB
testcase_36 AC 58 ms
16,364 KB
testcase_37 AC 191 ms
37,076 KB
testcase_38 AC 145 ms
15,204 KB
testcase_39 AC 333 ms
32,960 KB
testcase_40 AC 366 ms
34,784 KB
testcase_41 AC 352 ms
35,180 KB
testcase_42 AC 276 ms
37,884 KB
testcase_43 AC 369 ms
35,788 KB
testcase_44 AC 59 ms
6,932 KB
testcase_45 AC 393 ms
47,596 KB
testcase_46 AC 16 ms
4,640 KB
testcase_47 AC 102 ms
11,392 KB
testcase_48 AC 113 ms
29,848 KB
testcase_49 AC 101 ms
12,736 KB
testcase_50 AC 155 ms
28,732 KB
testcase_51 AC 185 ms
23,492 KB
testcase_52 AC 175 ms
22,524 KB
testcase_53 AC 349 ms
48,312 KB
testcase_54 AC 71 ms
21,880 KB
testcase_55 AC 7 ms
4,448 KB
testcase_56 AC 244 ms
32,080 KB
testcase_57 AC 150 ms
19,324 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
	vector<vector<int64_t>> hp(n, vector<int64_t>(n, 0));
	int num[n][n] = {};
	string s; cin >> s;
	int64_t a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	for(int l = 0; l < n; ++l) {
		int64_t sum = 0;
		int cnt = 0;
		for(int r = l; r < n; ++r) {
			sum += a[r];
			cnt += (s[r] == 'E');
			hp[l][r] = sum;
			num[l][r] = cnt;
		}
	}
	int q; cin >> q;
	while(q--) {
		int64_t k; cin >> k;
		int ans = 0;
		for(int l = 0; l < n; ++l) {
			int r = upper_bound(hp[l].begin(), hp[l].end(), k) - hp[l].begin() - 1;
			ans = max(ans, num[l][r]);
		}
		cout << ans << '\n';
	}
	return 0;
}
0