結果

問題 No.973 余興
ユーザー kwm_tkwm_t
提出日時 2023-06-30 15:37:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 745 ms / 4,000 ms
コード長 1,975 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 205,768 KB
実行使用メモリ 199,156 KB
最終ジャッジ日時 2023-09-21 09:15:06
合計ジャッジ時間 27,778 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 700 ms
199,156 KB
testcase_01 AC 686 ms
198,968 KB
testcase_02 AC 688 ms
199,128 KB
testcase_03 AC 685 ms
198,588 KB
testcase_04 AC 690 ms
198,868 KB
testcase_05 AC 693 ms
198,936 KB
testcase_06 AC 683 ms
198,608 KB
testcase_07 AC 689 ms
198,656 KB
testcase_08 AC 699 ms
198,172 KB
testcase_09 AC 685 ms
198,868 KB
testcase_10 AC 652 ms
191,000 KB
testcase_11 AC 191 ms
73,472 KB
testcase_12 AC 188 ms
73,572 KB
testcase_13 AC 190 ms
72,924 KB
testcase_14 AC 190 ms
72,992 KB
testcase_15 AC 17 ms
10,908 KB
testcase_16 AC 18 ms
11,228 KB
testcase_17 AC 10 ms
8,068 KB
testcase_18 AC 13 ms
9,368 KB
testcase_19 AC 13 ms
9,444 KB
testcase_20 AC 9 ms
7,696 KB
testcase_21 AC 18 ms
11,028 KB
testcase_22 AC 19 ms
10,948 KB
testcase_23 AC 13 ms
9,372 KB
testcase_24 AC 13 ms
9,372 KB
testcase_25 AC 7 ms
6,008 KB
testcase_26 AC 10 ms
7,720 KB
testcase_27 AC 22 ms
12,208 KB
testcase_28 AC 13 ms
9,324 KB
testcase_29 AC 13 ms
9,440 KB
testcase_30 AC 721 ms
198,868 KB
testcase_31 AC 728 ms
199,156 KB
testcase_32 AC 709 ms
198,864 KB
testcase_33 AC 723 ms
198,644 KB
testcase_34 AC 722 ms
198,060 KB
testcase_35 AC 718 ms
198,836 KB
testcase_36 AC 693 ms
193,716 KB
testcase_37 AC 691 ms
193,572 KB
testcase_38 AC 726 ms
198,176 KB
testcase_39 AC 707 ms
198,340 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 732 ms
198,988 KB
testcase_47 AC 714 ms
198,920 KB
testcase_48 AC 706 ms
198,880 KB
testcase_49 AC 649 ms
183,600 KB
testcase_50 AC 701 ms
197,336 KB
testcase_51 AC 717 ms
198,920 KB
testcase_52 AC 729 ms
198,996 KB
testcase_53 AC 700 ms
195,556 KB
testcase_54 AC 721 ms
198,916 KB
testcase_55 AC 745 ms
198,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, x; cin >> n >> x;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	vector<int>left(n), right(n);
	rep(_, 2) {
		long long sum = 0;
		int j = 0;
		for (int i = 0; i < n; ++i) {
			while (j < n && sum + a[j] <= x) {
				sum += a[j];
				j++;
			}
			left[i] = j - i;
			sum -= a[i];
		}
		reverse(all(a));
		swap(left, right);
	}
	reverse(all(right));
	// 手番の状態、勝ちなら1負けなら0を累積和で持つ
	vector dpl(n, vector<int>(n + 2, 0));
	vector dpr(n, vector<int>(n + 2, 0));
	rep2(i, 1, n + 1) {
		rep(j, n) {
			// 閉区間
			int l = j;
			int r = l + i - 1;
			if (r >= n)break;
			dpl[l][i + 1] = dpl[l][i];
			dpr[r][i + 1] = dpr[r][i];
			{
				int can = min(i - 1, left[l]);
				int x = dpr[r][i] - dpr[r][i - can];
				if (x != can) {
					dpl[l][i + 1]++;
					dpr[r][i + 1]++;
					continue;
				}
			}
			int can = min(i - 1, right[r]);
			int x = dpl[l][i] - dpl[l][i - can];
			if (x != can) {
				dpl[l][i + 1]++;
				dpr[r][i + 1]++;
			}
		}
	}
	if (dpl[0][n + 1] - dpl[0][n])cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}
0