結果

問題 No.973 余興
ユーザー QCFiumQCFium
提出日時 2020-08-01 00:57:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 307 ms / 4,000 ms
コード長 1,022 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 166,756 KB
実行使用メモリ 28,164 KB
最終ジャッジ日時 2023-09-21 04:42:05
合計ジャッジ時間 13,973 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
28,008 KB
testcase_01 AC 301 ms
28,096 KB
testcase_02 AC 299 ms
28,000 KB
testcase_03 AC 307 ms
27,996 KB
testcase_04 AC 301 ms
28,008 KB
testcase_05 AC 302 ms
27,944 KB
testcase_06 AC 304 ms
28,064 KB
testcase_07 AC 307 ms
27,876 KB
testcase_08 AC 307 ms
27,936 KB
testcase_09 AC 307 ms
27,948 KB
testcase_10 AC 287 ms
26,936 KB
testcase_11 AC 78 ms
12,224 KB
testcase_12 AC 81 ms
12,216 KB
testcase_13 AC 79 ms
12,148 KB
testcase_14 AC 78 ms
12,144 KB
testcase_15 AC 14 ms
4,504 KB
testcase_16 AC 14 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 12 ms
4,376 KB
testcase_19 AC 12 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 13 ms
4,528 KB
testcase_22 AC 13 ms
4,384 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 11 ms
4,380 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 9 ms
4,380 KB
testcase_27 AC 16 ms
4,680 KB
testcase_28 AC 11 ms
4,376 KB
testcase_29 AC 11 ms
4,380 KB
testcase_30 AC 281 ms
27,976 KB
testcase_31 AC 282 ms
28,164 KB
testcase_32 AC 279 ms
27,948 KB
testcase_33 AC 290 ms
27,928 KB
testcase_34 AC 281 ms
28,124 KB
testcase_35 AC 285 ms
28,032 KB
testcase_36 AC 267 ms
27,424 KB
testcase_37 AC 267 ms
27,240 KB
testcase_38 AC 283 ms
28,128 KB
testcase_39 AC 286 ms
27,956 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 279 ms
27,940 KB
testcase_47 AC 277 ms
27,904 KB
testcase_48 AC 281 ms
27,956 KB
testcase_49 AC 251 ms
26,048 KB
testcase_50 AC 276 ms
27,916 KB
testcase_51 AC 275 ms
28,024 KB
testcase_52 AC 281 ms
28,072 KB
testcase_53 AC 281 ms
27,584 KB
testcase_54 AC 281 ms
27,976 KB
testcase_55 AC 277 ms
27,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int x = ri();
	int a[n];
	for (auto &i : a) i = ri();
	
	int64_t sum[n + 1];
	sum[0] = 0;
	for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
	
	bool dp[n + 1][n + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= n; i++) dp[i][i] = false;
	int tail0[n + 1], tail1[n + 1];
	int cur_sum0[n + 1], cur_sum1[n + 1];
	for (int i = 0; i <= n; i++) {
		tail0[i] = tail1[i] = i;
		cur_sum0[i] = cur_sum1[i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			cur_sum0[j + i] += dp[j + 1][j + i];
			while (tail0[j + i] > j && sum[tail0[j + i]] - sum[j] > x)
				cur_sum0[j + i] -= dp[tail0[j + i]--][j + i];
			dp[j][j + i] |= cur_sum0[j + i];
			
			cur_sum1[j] += dp[j][j + i - 1];
			while (tail1[j] < j + i && sum[j + i] - sum[tail1[j]] > x)
				cur_sum1[j] -= dp[j][tail1[j]++];
			dp[j][j + i] |= cur_sum1[j];
			dp[j][j + i] ^= 1;
		}
	}
	puts(dp[0][n] ? "B" : "A");
	return 0;
}
0