結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー merom686
提出日時 2019-11-29 22:41:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 76,136 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 05:51:36
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    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;

    for (int h = 0; h < q; h++) {
        int k;
        cin >> k;

        int i0 = 0, i1 = 0;
        int r = 0, x = 0, y = 0;
        for (; i0 < n;) {
            while (i1 < n && x + a[i1] <= k) {
                x += a[i1];
                y += s[i1] == 'E';
                i1++;
            }
            r = max(r, y);

            x -= a[i0];
            y -= s[i0] == 'E';
            i0++;
        }
        cout << r << '\n';
    }

    return 0;
}
0