#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i @hamayanhamayan0     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, X, A[5010]; int lft[5010][5010], rht[5010][5010]; //--------------------------------------------------------------------------------------------------- ll B[5010]; // [l,r] ll get(int l, int r) { ll res = B[r]; if (l) res -= B[l - 1]; return res; } //--------------------------------------------------------------------------------------------------- int ng_lft[5010], ng_rht[5010]; void make_ng() { rep(len, 2, N + 1) { int ng = 0; rep(l, 0, N - len + 1) { int r = l + len - 1; while (ng <= l) ng++; while (ng <= r and get(l, ng) <= X) ng++; ng_lft[l] = ng; } ng = N; rrep(r, N - len, len - 1) { int l = r - len + 1; while (r <= ng) ng--; while (l <= ng and get(ng, r) <= X) ng--; ng_rht[r] = ng; } } } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> X; rep(i, 0, N) cin >> A[i]; if (N == 1) { cout << "B" << endl; return; } B[0] = A[0]; rep(i, 1, N) B[i] = B[i - 1] + A[i]; make_ng(); rep(i, 0, N) { lft[i][i] = 1; rht[i][i] = 1; } rep(len, 2, N + 1) { int ng = 0; rep(l, 0, N - len + 1) { int r = l + len - 1; rht[r][l] = rht[r][l + 1]; lft[l][r] = lft[l][r - 1]; int tot = rht[r][ng_lft[l] - 1] - rht[r][l]; int cnt = ng_lft[l] - 1 - (l + 1) + 1; if (tot != cnt) { rht[r][l]++; lft[l][r]++; continue; } tot = lft[l][r] - lft[l][ng_rht[r]]; cnt = r - (ng_rht[r] + 1) + 1; if (tot != cnt) { rht[r][l]++; lft[l][r]++; continue; } } } if (lft[0][N - 1] == lft[0][N - 2] + 1) cout << "A" << endl; else cout << "B" << endl; }