結果

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

ソースコード

diff #
raw source code

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

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;

#define fastio ios::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) (x).begin(), (x).end()

int main() {
    // fastio;

    int n , e;
    string s;
    int total_powers=0 , total_e = 0 ; 
    cin >> n;
    vector<int>s_powers(n);
    cin >> s;
    
    for(int i=0;i<n;i++){
        if(s[i]=='E') total_e++;
    }
    
    for(int i=0;i<n;i++){
        cin >> s_powers[i];
        total_powers += s_powers[i];
    }
    
    cin >> e;
    vector<int>t(e);
    for(int i=0;i<e;i++)cin >> t[i];

    // main loop 
    for(int b=0;b<e;b++){
        if(total_powers <= t[b]){
            cout << total_e << "\n";
            continue;
        }
        int e_count = 0 ,is_active = false;
        vector<pair<int,int>> spots(n);

        for(int i=0;i<n;i++){
        if(s[i]=='E'){
            if(!is_active){ 
                spots[e_count].first = i;
                is_active = true;
            }
        }
        else{
            if(is_active){
                spots[e_count++].second = i-1;
                is_active =false; 
            }
        }
        }

        int spots_len = e_count;

        if(is_active) {spots[e_count].second = n-1; spots_len++;}
        
        // brute force for max outcome 
        int max = 0;
        for(int i=0;i<spots_len;i++){
            int current_s_power = t[b];
            int local_max = 0;
            for(int j=spots[i].first;j<=spots[i].second;j++){
                if(current_s_power >= s_powers[j] ) {
                    local_max++;
                    current_s_power-=s_powers[j];
                }
                else{
                    break;
                }
            }
            if(local_max > max) {
                max = local_max;
            }
        }
        cout << max << "\n";
    }
    



    return 0;
}
0