結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー Knots
提出日時 2020-11-27 09:28:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,100 bytes
コンパイル時間 3,429 ms
コンパイル使用メモリ 194,208 KB
最終ジャッジ日時 2025-01-16 06:00:08
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"
#define COUT16(x) cout << fixed << setprecision(16) << (x) << "\n";

int main(){
    int n,q;cin >> n;
    string s;cin >> s;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    cin >> q;
    vector<int> k(q);
    REP(i,q) cin >> k[i];
    for(int i=0;i<q;i++){
        int ans = 0;
        int right = 0;
        for(int left=0;left<n;left++){
            ll attack = 0;
            int tes = 0;
            while(right<n&&attack+a[right]<=k[i]){
                attack += a[right];
                if(s[right]=='E')tes++;
                right++;
            }
            ans = max(ans,tes);
            if(left==right)++right;
            else tes -= a[left];
        }
        COUT(ans);
    }
}
    
0