結果

問題 No.973 余興
ユーザー ks2mks2m
提出日時 2020-01-17 23:16:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,462 bytes
コンパイル時間 4,424 ms
コンパイル使用メモリ 74,084 KB
実行使用メモリ 60,516 KB
最終ジャッジ日時 2023-09-08 07:13:17
合計ジャッジ時間 61,419 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
53,136 KB
testcase_01 AC 108 ms
54,928 KB
testcase_02 AC 99 ms
52,408 KB
testcase_03 AC 100 ms
52,588 KB
testcase_04 AC 108 ms
55,136 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 91 ms
53,084 KB
testcase_11 AC 1,149 ms
59,912 KB
testcase_12 AC 698 ms
57,248 KB
testcase_13 WA -
testcase_14 AC 1,125 ms
59,580 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 55 ms
47,556 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 62 ms
50,768 KB
testcase_23 AC 61 ms
50,764 KB
testcase_24 AC 61 ms
50,844 KB
testcase_25 AC 56 ms
51,380 KB
testcase_26 AC 59 ms
50,324 KB
testcase_27 AC 58 ms
50,496 KB
testcase_28 WA -
testcase_29 AC 61 ms
50,468 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,619 ms
56,592 KB
testcase_35 AC 3,102 ms
59,680 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,625 ms
56,864 KB
testcase_39 WA -
testcase_40 AC 44 ms
49,484 KB
testcase_41 AC 45 ms
49,560 KB
testcase_42 AC 46 ms
49,148 KB
testcase_43 WA -
testcase_44 AC 45 ms
49,540 KB
testcase_45 WA -
testcase_46 AC 3,913 ms
59,244 KB
testcase_47 WA -
testcase_48 AC 1,948 ms
56,260 KB
testcase_49 WA -
testcase_50 AC 3,961 ms
58,996 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,001 ms
57,268 KB
testcase_54 AC 1,769 ms
59,496 KB
testcase_55 AC 1,766 ms
57,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int x = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		for (int i = 0; i < n; i++) {
			int[] dp = new int[n];
			for (int r = i + 1; r < n; r++) {
				TreeSet<Integer> set = new TreeSet<>();
				long sum = a[r];
				for (int k = r - 1; k >= i; k--) {
					if (k == i) {
						set.add(0);
						break;
					}
					sum += a[k];
					set.add(dp[k]);
					if (sum > x) {
						break;
					}
				}
				for (int j = 0; j < n; j++) {
					if (!set.contains(j)) {
						dp[r] = j;
						break;
					}
				}
			}
			for (int r = i - 1; r >= 0; r--) {
				TreeSet<Integer> set = new TreeSet<>();
				long sum = a[r];
				for (int k = r + 1; k <= i; k++) {
					if (k == i) {
						set.add(0);
						break;
					}
					sum += a[k];
					set.add(dp[k]);
					if (sum > x) {
						break;
					}
				}
				for (int j = 0; j < n; j++) {
					if (!set.contains(j)) {
						dp[r] = j;
						break;
					}
				}
			}
			if (dp[0] != dp[n - 1]) {
				System.out.println("A");
				return;
			}
		}
		System.out.println("B");
	}
}
0