結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
コンテスト
ユーザー vjudge1
提出日時 2026-01-03 17:48:29
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,017 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,217 ms
コンパイル使用メモリ 337,500 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-01-03 17:48:34
合計ジャッジ時間 5,689 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//
// c.cpp
// Created by wasifshahzad on 01/03/26 at 12:52:34.
//

#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

const int MOD1 = 1e9+7;
const int MOD2 = 998244353;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int q;
    cin >> q;
    while(q--) {
        int k;
        cin >> k;
        int ans = 0;
        int l = -1, sum = 0, cnt = 0;
        for(int r = 0; r < n; r++) {
            sum += a[r];
            cnt += s[r] == 'E';
            while(sum > k && l + 1 <= r) {
                sum -= a[l + 1];
                cnt -= s[l + 1] == 'E';
                l++;
            }
            ans = max(ans, cnt);
        }
        cout << ans << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
}
0