結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-11-29 22:22:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,591 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 100,116 KB
実行使用メモリ 34,468 KB
最終ジャッジ日時 2023-08-13 06:39:13
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 5 ms
5,644 KB
testcase_02 AC 5 ms
6,716 KB
testcase_03 AC 9 ms
10,464 KB
testcase_04 AC 15 ms
17,616 KB
testcase_05 AC 8 ms
10,208 KB
testcase_06 AC 11 ms
10,976 KB
testcase_07 AC 12 ms
13,060 KB
testcase_08 AC 30 ms
33,440 KB
testcase_09 AC 18 ms
19,976 KB
testcase_10 AC 19 ms
21,024 KB
testcase_11 AC 27 ms
29,632 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 31 ms
34,468 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr ll INF = 1LL << 60;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> hp(n);
    for(int i=0;i<n;++i){
        cin >> hp[i];
    }

    vector<vector<ll>> hp_sum(n, vector<ll>(n+1, INF));   
    // hp_sum[i][j] := i番目の E or W から (i 番目を含む) j 体倒すのに必要な威力
    vector<ll> min_k(n+2, INF);
    // min_k[i] := i 体倒すのに必要な最小威力
    min_k[0] = 0;
    int n_enemy = 0;
    for(int i=0;i<n;++i) {
        hp_sum[i][0] = 0;
        for(int j=i;j<n;++j) {
            hp_sum[i][j-i+1] = hp_sum[i][j-i] + hp[j];
            if(s[j] == 'E') min_k[j-i+1] = min(min_k[j-i+1], hp_sum[i][j-i+1]);
        }
        if(s[i] == 'E') ++n_enemy;
    }

    int q;
    ll k;
    cin >> q;
    while(q--) {
        cin >> k;
        auto itr = upper_bound(min_k.begin(), min_k.end(), k);
        cout << max(min(int(distance(min_k.begin(), itr))-1, n_enemy), 0) << endl;
    }
}
0