#include using namespace std; #define int long long #define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define all(x) (x).begin(),(x).end() #define sz(x) ((int)x.size()) templatebool chmax(T &a,T b){if(abool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;} /* */ using vi = vector; using vvi = vector; using P = pair; signed main() { int n, x; cin >> n >> x; vi a(n); rep(i, 0, n) cin >> a[i]; vi lr(n), rl(n); { int r = 0, sum = 0; rep(l, 0, n){ while(r < n and sum + a[r] <= x){ sum += a[r]; r++; } lr[l] = r-1; if(l == r) r++; else sum -= a[l]; } } { int l = n-1, sum = 0; for(int r = n-1; r >= 0; r--){ while(l >= 0 and sum + a[l] <= x){ sum += a[l]; l--; } rl[r] = l+1; if(l == r) l--; else sum -= a[r]; } } vvi dp(n+1, vi(n, 1)); // dp[len][left] rep(len, 2, n+1){ vi sdp(n+1); rep(i, 0, n) sdp[i+1] = sdp[i] + dp[len-1][i]; rep(left, 0, n){ if(left+len-1 >= n) break; int l = left, r = left+len-1; int s = lr[l], t = rl[r]; if(sdp[s+1]-sdp[l] > 0){ dp[len][left] = 0; } if(sdp[r+1]-sdp[t] > 0){ dp[len][left] = 0; } } } // rep(len, 0, n+1) { // rep(left, 0, n) { // cout << dp[len][left] << " "; // } // cout << endl; // } if(dp[n][0]) cout << "B" << endl; else cout << "A" << endl; return 0; }