結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー kya_skikya_ski
提出日時 2019-11-29 22:59:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,117 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 173,344 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 00:43:57
合計ジャッジ時間 5,567 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 34 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 38 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 6 ms
6,944 KB
testcase_06 AC 70 ms
6,944 KB
testcase_07 AC 68 ms
6,940 KB
testcase_08 AC 166 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 122 ms
6,940 KB
testcase_11 AC 147 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 5 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 57 ms
6,944 KB
testcase_21 AC 8 ms
6,940 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 WA -
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,944 KB
testcase_31 WA -
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 68 ms
6,940 KB
testcase_34 AC 115 ms
6,940 KB
testcase_35 AC 103 ms
6,940 KB
testcase_36 AC 25 ms
6,940 KB
testcase_37 AC 67 ms
6,944 KB
testcase_38 WA -
testcase_39 AC 126 ms
6,940 KB
testcase_40 AC 135 ms
6,944 KB
testcase_41 AC 135 ms
6,940 KB
testcase_42 WA -
testcase_43 AC 143 ms
6,940 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 15 ms
6,940 KB
testcase_47 AC 54 ms
6,940 KB
testcase_48 WA -
testcase_49 AC 47 ms
6,940 KB
testcase_50 AC 57 ms
6,940 KB
testcase_51 AC 75 ms
6,940 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 27 ms
6,940 KB
testcase_55 AC 6 ms
6,944 KB
testcase_56 WA -
testcase_57 AC 70 ms
6,944 KB
testcase_58 AC 2 ms
6,944 KB
testcase_59 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:35:17: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
   35 |             int res;
      |                 ^~~

ソースコード

diff #

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

template<typename T> int SumDigit(T N) {
	int res = 0;
	while(N > 0) { res += (N % 10); N /= 10; }
	return res;
}

int main(){
    int N, Q;
    string S;
    cin >> N >> S;
    vector<long long> HP(N);
    vector<long long> sum(N+1, 0);
    vector<int> ene(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> HP[i];
        sum[i+1] = sum[i] + HP[i];
        ene[i+1] = ene[i];
        if (S[i] == 'E') ene[i+1]++;
    }

    cin >> Q;
    for (int i = 0; i < Q; i++) {
        long long K; cin >> K;
        int ans = 0;
        if (sum[N] <= K) {
            cout << ene[N] << endl;
            continue;
        }
        for (int j = 0; j < N; j++) {
            long long k = K + sum[j];
            int m = lower_bound(sum.begin(), sum.end(), k) - sum.begin();
            int res;
            if (m > 0 && sum[m-1] <= k) res = ene[m-1] - ene[j];
            if (sum[m] <= k) res = ene[m] - ene[j];
            if (m < N && sum[m+1] <= k) res = ene[m+1] - ene[j];
            ans = max(ans, res);
        }
        cout << ans << endl;
    }
    return 0;
}
0