結果

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

ソースコード

diff #
raw source code

    #include <bits/stdc++.h>
    using namespace std;
    #define int long long int
    #define forn(i, a, n) for (int i = a; i < n; i++)
    #define fornr(i, a, n) for (int i = n - 1; i >= a; i--)
    #define print(a) cout << a << "\n";
    #define printarr(a) forn(i, 0, a.size()) cout << a[i] << " "; cout << endl;
    #define file_read(filepath) freopen(filepath, "r", stdin);
    #define file_write(filepath) freopen(filepath, "w", stdout);
    #define f first
    #define s second
    #define pb push_back
    #define all(a) a.begin(), a.end()
    #define rall(a) a.rbegin(), a.rend()
    #define sorted(a) is_sorted(all(a))
    #define vi vector<int>
    #define vvi vector<vector<int>>
    #define vc vector<char>
    #define vs vector<string>
    #define pii pair<int,int>
    #define pis pair<int,string>
    #define psi pair<string,int>
    #define vpii vector<pair<int,int>>
    #define MOD1 1000000007
    #define mii map<int,int>
    #define sz(a) (int)a.size()
    #define ld long double
    #define add insert

    void solve(){
        int n;
        cin >> n;
        string s;
        cin >> s;
        vector<int> a(n);
        forn(i,0,n) cin >> a[i];
        vi e(n), w(n);
        forn(i,0,n){
            e[i] += (s[i] == 'E');
            w[i] += (s[i] == 'W');
        }
        int q;
        cin >> q;
        while(q--){
            int k;
            cin >> k;
            int ans = 0;
            for(int i = 0; i < n; i++){
                int sum = 0, ec = 0;
                for(int j = i; j < n; j++){
                    if(sum + a[j] <= k){
                        sum += a[j];
                        ec += (s[j] == 'E');
                    } else break;
                }
                ans = max(ans, ec);
            }
            print(ans)
        }
    }

    signed main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while(t--){
            solve();
        }
    }
0