#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } signed main(){ int n;ll x;cin>>n>>x; vector v(n); cin>>v; vector t_l(n),t_r(n);// can take [i, t_l[i]], [t_r[i], i] vector s(n); s[0]=v[0]; for(int i=1;ix) break; } t_l[i]=j-1; } { ll sum=0; int j; for(j=i;j>=0;j--){ sum+=v[j]; if(sum>x) break; } t_r[i]=j+1; } } vector> L(n+2,vector(n+2,0)),R(n+2,vector(n+2,0)); rep(i,n) L[i][i]=1,R[i][i]=1; auto getL=[&](int R,int l,int r){ int ret=L[l][R]; if(r+1<=n) ret-=L[r+1][R]; return ret; }; auto getR=[&](int L,int l,int r){ int ret=R[L][r]; if(l) ret-=R[L][l-1]; return ret; }; bool res=false; for(int w=2;w<=n;w++){ for(int l=0;l+w<=n;l++){ int r=l+w-1; bool win=false; int a=t_l[l];// can eat [l,a] int b=t_r[r];// [b,r] if(getL(r,l+1,a+1)) win=true; if(getR(l,b-1,r-1)) win=true; L[l][r]=L[l+1][r]; R[l][r]=R[l][r-1]; if(!win){ L[l][r]++; R[l][r]++; } if(l==0 and r==n-1) res=win; } } cout<<("BA"[res])<