#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; int dp[5050][5050]; int s1[5050][5050]; int s2[5050][5050]; ll a[5050]; ll s[5050]; int n; ll x; int main() { int n; ll x; cin>>n>>x; for(int i=0; i>a[i]; s[i+1]=s[i]+a[i]; } for(int i=0; i0){ dp[l][r]=0; s1[l][r]=s1[l+1][r]+dp[l][r]; s2[l][r]=s2[l][r-1]+dp[l][r]; continue; } k=lower_bound(s, s+n+1, s[r+1]-x)-s; k=max(k, l+1); if(s2[l][r-1]-s2[l][k-2]>0){ dp[l][r]=0; }else{ dp[l][r]=1; } s1[l][r]=s1[l+1][r]+dp[l][r]; s2[l][r]=s2[l][r-1]+dp[l][r]; } } if(dp[0][n-1]) cout<<"B"<