#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define range(a) a.begin(), a.end() int main() { int N; cin >> N; ll X; cin >> X; vector A(N); rep(i, N) cin >> A[i]; vector S(N + 1); rep(i, N) S[i + 1] = S[i] + A[i]; vector R(N + 1); repr(i, N) R[i] = R[i + 1] + A[i]; vector> dp(N, vector(N)); vector> eplr(N, vector(N)); vector> eprl(N, vector(N)); for (int d = 1; d <= N - 1; d++) { for (int l = 0; l + d <= N - 1; l++) { int r = l + d; // dpl[l][r]...dpl[x][r] -> 0 // dpr[l][y]...dpr[l][r] -> 0 int x, y; { int lo = l + 1; int hi = r + 1; while (hi - lo > 1) { int mid = (lo + hi) / 2; if (S[mid] - S[l] <= X) { lo = mid; } else { hi = mid; } } x = lo; } { int lo = l - 1; int hi = r - 1; while (hi - lo > 1) { int mid = (lo + hi) / 2; if (S[r + 1] - S[mid] <= X) { hi = mid; } else { lo = mid; } } y = hi; } if (eprl[r][l + 1] - eprl[r][x] + dp[x][r] != x - (l + 1) + 1) { dp[l][r] = 1; } if (eplr[l][r - 1] - eplr[l][y] + dp[l][y] != (r - 1) - y + 1) { dp[l][r] = 1; } eplr[l][r] = dp[l][r] + eplr[l][r - 1]; eprl[r][l] = dp[l][r] + eprl[r][l + 1]; } } cout << (dp[0][N - 1] ? "A" : "B") << endl; }