結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー face4face4
提出日時 2019-11-29 22:15:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,047 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 124,416 KB
最終ジャッジ日時 2024-05-01 00:31:58
合計ジャッジ時間 15,226 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
13,764 KB
testcase_01 AC 118 ms
14,208 KB
testcase_02 AC 170 ms
17,792 KB
testcase_03 AC 441 ms
33,024 KB
testcase_04 AC 965 ms
60,800 KB
testcase_05 AC 406 ms
31,872 KB
testcase_06 AC 505 ms
35,200 KB
testcase_07 AC 605 ms
43,392 KB
testcase_08 TLE -
testcase_09 AC 1,243 ms
70,912 KB
testcase_10 AC 1,268 ms
74,368 KB
testcase_11 TLE -
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> e(n, 0);
    for(int i = 0; i < n; i++){
        if(i)   e[i] += e[i-1];
        e[i] += s[i]=='E';
    }
    vector<ll> sum(n);
    for(int i = 0; i < n; i++){
        cin >> sum[i];
        if(i)   sum[i] += sum[i-1];
    }
    map<ll,int> m;
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            int tmp = e[j] - (i==0 ? 0 : e[i-1]);
            if(tmp == 0)    continue;
            ll p = sum[j] - (i==0 ? 0 : sum[i-1]);
            if(m.count(p))  m[p] = max(m[p], tmp);
            else            m[p] = tmp;
        }
    }
    auto bef = m.begin();
    for(auto it = ++m.begin(); it != m.end(); it++){
        m[it->first] = max(it->second, bef->second);
        bef = it;
    }
    m[0] = 0;
    int q;
    cin >> q;
    while(q-- > 0){
        ll k;
        cin >> k;
        cout << (--m.upper_bound(k))->second << endl;
    }
    return 0;
}
0