#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; template using posteriority_queue = priority_queue, greater >; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; // const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } template void unique(vector &a) { a.erase(unique(ALL(a)), a.end()); } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; int main() { int n, x; cin >> n >> x; if (n == 1) { cout << "B\n"; return 0; } vector a(n); REP(i, n) cin >> a[i]; vector l(n, 0), r(n, 0); REP(i, n) { int sum = a[i], j = i + 1; while (j < n && sum + a[j] <= x) sum += a[j++]; l[i] = j - i; } REP(i, n) { int sum = a[i], j = i - 1; while (j >= 0 && sum + a[j] <= x) sum += a[j--]; r[i] = i - j; } vector > dp_l(n, vector(n, 0)), dp_r(n, vector(n, 0)); FOR(len, 2, n + 1) { REP(i, n) { int j = i + len - 1; if (j >= n) break; int chou = min(len - 1, l[i]); if (dp_r[i + 1][j] - (i + chou + 1 >= n ? 0 : dp_r[i + chou + 1][j]) != chou) { dp_l[i][j] = dp_l[i][j - 1] + 1; dp_r[i][j] = dp_r[i + 1][j] + 1; continue; } chou = min(len - 1, r[j]); if (dp_l[i][j - 1] - (j - chou - 1 < 0 ? 0 : dp_l[i][j - chou - 1]) != chou) { dp_l[i][j] = dp_l[i][j - 1] + 1; dp_r[i][j] = dp_r[i + 1][j] + 1; continue; } dp_l[i][j] = dp_l[i][j - 1]; dp_r[i][j] = dp_r[i + 1][j]; } } // REP(i, n) FOR(j, i, n) cout << i << ' ' << j << " : " << dp_r[i][j] << '\n'; cout << (dp_l[0][n - 1] - dp_l[0][n - 2] == 1 ? "A\n" : "B\n"); return 0; }