結果

問題 No.973 余興
ユーザー kwm_tkwm_t
提出日時 2023-06-30 15:36:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 807 ms / 4,000 ms
コード長 2,004 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 204,888 KB
実行使用メモリ 199,128 KB
最終ジャッジ日時 2023-09-21 09:13:01
合計ジャッジ時間 30,422 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 782 ms
198,904 KB
testcase_01 AC 778 ms
199,080 KB
testcase_02 AC 781 ms
198,936 KB
testcase_03 AC 769 ms
198,724 KB
testcase_04 AC 780 ms
198,988 KB
testcase_05 AC 775 ms
198,992 KB
testcase_06 AC 766 ms
198,652 KB
testcase_07 AC 784 ms
198,860 KB
testcase_08 AC 776 ms
198,180 KB
testcase_09 AC 783 ms
198,864 KB
testcase_10 AC 738 ms
190,916 KB
testcase_11 AC 239 ms
73,588 KB
testcase_12 AC 246 ms
73,596 KB
testcase_13 AC 241 ms
73,060 KB
testcase_14 AC 241 ms
73,060 KB
testcase_15 AC 19 ms
10,876 KB
testcase_16 AC 20 ms
11,164 KB
testcase_17 AC 10 ms
8,120 KB
testcase_18 AC 13 ms
9,440 KB
testcase_19 AC 14 ms
9,328 KB
testcase_20 AC 10 ms
7,860 KB
testcase_21 AC 19 ms
10,908 KB
testcase_22 AC 20 ms
11,024 KB
testcase_23 AC 13 ms
9,288 KB
testcase_24 AC 13 ms
9,416 KB
testcase_25 AC 7 ms
5,876 KB
testcase_26 AC 10 ms
7,856 KB
testcase_27 AC 24 ms
12,268 KB
testcase_28 AC 14 ms
9,372 KB
testcase_29 AC 13 ms
9,580 KB
testcase_30 AC 800 ms
198,992 KB
testcase_31 AC 798 ms
198,920 KB
testcase_32 AC 794 ms
198,968 KB
testcase_33 AC 788 ms
198,656 KB
testcase_34 AC 793 ms
198,048 KB
testcase_35 AC 789 ms
198,916 KB
testcase_36 AC 776 ms
193,656 KB
testcase_37 AC 759 ms
193,656 KB
testcase_38 AC 791 ms
198,284 KB
testcase_39 AC 798 ms
198,468 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 798 ms
199,128 KB
testcase_47 AC 807 ms
198,656 KB
testcase_48 AC 801 ms
198,932 KB
testcase_49 AC 728 ms
183,556 KB
testcase_50 AC 782 ms
197,260 KB
testcase_51 AC 786 ms
198,852 KB
testcase_52 AC 805 ms
198,996 KB
testcase_53 AC 773 ms
195,696 KB
testcase_54 AC 794 ms
198,856 KB
testcase_55 AC 798 ms
198,996 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 + 0] = dpl[l][i - 1];
			dpr[r][i + 0] = dpr[r][i - 1];
			{
				int can = min(i - 1, left[l]);
				int x = dpr[r][i - 1] - dpr[r][i - can - 1];
				if (x != can) {
					dpl[l][i + 0]++;
					dpr[r][i + 0]++;
					continue;
				}
			}
			int can = min(i - 1, right[r]);
			int x = dpl[l][i - 1] - dpl[l][i - can - 1];
			if (x != can) {
				dpl[l][i + 0]++;
				dpr[r][i + 0]++;
			}
		}
	}
	if (dpl[0][n + 0] == dpl[0][n - 1])cout << "B" << endl;
	else cout << "A" << endl;
	return 0;
}
0