結果

問題 No.973 余興
ユーザー tentententen
提出日時 2021-03-01 14:58:09
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,150 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 77,832 KB
実行使用メモリ 85,832 KB
最終ジャッジ日時 2024-04-14 03:43:14
合計ジャッジ時間 17,560 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 757 ms
85,832 KB
testcase_01 AC 762 ms
78,704 KB
testcase_02 AC 768 ms
78,876 KB
testcase_03 AC 770 ms
78,852 KB
testcase_04 AC 794 ms
79,000 KB
testcase_05 AC 759 ms
78,828 KB
testcase_06 AC 785 ms
79,028 KB
testcase_07 AC 770 ms
78,688 KB
testcase_08 AC 776 ms
78,844 KB
testcase_09 AC 765 ms
78,944 KB
testcase_10 AC 764 ms
78,864 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] cals = new int[n];
        for (int i = 0; i < n; i++) {
            cals[i] = sc.nextInt();
        }
        boolean[][] dp = new boolean[n][n];
        for (int i = 1; i < n; i++) {
            for (int j = 0; j + i < n; j++) {
                int sum = 0;
                for (int k = j; !dp[j][j + i]; k++) {
                    sum += cals[k];
                    if (sum > x) {
                        break;
                    }
                    dp[j][j + i] = !dp[k + 1][j + i];
                }
                sum = 0;
                for (int k = j + i; !dp[j][j + i]; k--) {
                    sum += cals[k];
                    if (sum > x) {
                        break;
                    }
                    dp[j][j + i] = !dp[j][k - 1];
                }
            }
        }
        if (dp[0][n - 1]) {
            System.out.println("A");
        } else {
            System.out.println("B");
        }
    }
}
0