結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー htensaihtensai
提出日時 2020-02-06 10:37:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 1,269 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 77,088 KB
実行使用メモリ 61,956 KB
最終ジャッジ日時 2023-10-25 09:54:46
合計ジャッジ時間 18,054 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 207 ms
59,980 KB
testcase_01 AC 222 ms
60,252 KB
testcase_02 AC 204 ms
57,776 KB
testcase_03 AC 226 ms
60,004 KB
testcase_04 AC 235 ms
58,376 KB
testcase_05 AC 217 ms
58,032 KB
testcase_06 AC 232 ms
60,416 KB
testcase_07 AC 226 ms
59,744 KB
testcase_08 AC 260 ms
60,852 KB
testcase_09 AC 249 ms
60,240 KB
testcase_10 AC 249 ms
60,388 KB
testcase_11 AC 271 ms
60,876 KB
testcase_12 AC 132 ms
57,284 KB
testcase_13 AC 131 ms
57,308 KB
testcase_14 AC 131 ms
57,324 KB
testcase_15 AC 130 ms
57,276 KB
testcase_16 AC 138 ms
57,000 KB
testcase_17 AC 318 ms
61,956 KB
testcase_18 AC 240 ms
60,444 KB
testcase_19 AC 235 ms
60,424 KB
testcase_20 AC 241 ms
60,632 KB
testcase_21 AC 201 ms
57,752 KB
testcase_22 AC 211 ms
57,552 KB
testcase_23 AC 148 ms
57,444 KB
testcase_24 AC 164 ms
57,624 KB
testcase_25 AC 159 ms
57,552 KB
testcase_26 AC 150 ms
57,556 KB
testcase_27 AC 138 ms
57,464 KB
testcase_28 AC 148 ms
57,596 KB
testcase_29 AC 156 ms
57,524 KB
testcase_30 AC 148 ms
57,432 KB
testcase_31 AC 148 ms
57,404 KB
testcase_32 AC 157 ms
57,536 KB
testcase_33 AC 258 ms
60,564 KB
testcase_34 AC 250 ms
60,412 KB
testcase_35 AC 254 ms
60,624 KB
testcase_36 AC 225 ms
59,992 KB
testcase_37 AC 242 ms
59,976 KB
testcase_38 AC 232 ms
59,796 KB
testcase_39 AC 254 ms
60,336 KB
testcase_40 AC 256 ms
60,496 KB
testcase_41 AC 259 ms
60,404 KB
testcase_42 AC 246 ms
60,288 KB
testcase_43 AC 251 ms
60,500 KB
testcase_44 AC 229 ms
60,560 KB
testcase_45 AC 267 ms
60,492 KB
testcase_46 AC 207 ms
57,628 KB
testcase_47 AC 229 ms
60,064 KB
testcase_48 AC 240 ms
60,256 KB
testcase_49 AC 228 ms
59,948 KB
testcase_50 AC 238 ms
60,348 KB
testcase_51 AC 240 ms
60,300 KB
testcase_52 AC 241 ms
59,996 KB
testcase_53 AC 265 ms
60,624 KB
testcase_54 AC 232 ms
60,144 KB
testcase_55 AC 197 ms
57,512 KB
testcase_56 AC 249 ms
60,116 KB
testcase_57 AC 233 ms
60,004 KB
testcase_58 AC 121 ms
56,152 KB
testcase_59 AC 132 ms
57,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        int[] eSums = new int[n + 1];
        long[] sSums = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            eSums[i] = eSums[i - 1];
            if (arr[i - 1] == 'E') {
                eSums[i]++;
            }
            sSums[i] = sSums[i - 1];
            sSums[i] += sc.nextInt();
            
        }
        int max = eSums[n];
        long[] scores = new long[max + 1];
        Arrays.fill(scores, Long.MAX_VALUE);
        scores[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int count = eSums[j] - eSums[i];
                scores[count] = Math.min(scores[count], sSums[j] - sSums[i]);
            }
        }
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            int idx = 0;
            while (idx < max && scores[idx + 1] <= x) {
                idx++;
            }
            sb.append(idx).append("\n");
        }
        System.out.print(sb);
    }
}
0