#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; } vector> dp(5001); void naive(){ int n;ll x;cin>>n>>x; vector v(n); cin>>v; for(int w=2;w<=n;w++){ for(int l=0;l+w<=n;l++){ int r=l+w;// [l,r) bool win=false; // left { ll s=v[l]; for(int i=l+1;il and s<=x;i--){ if(!dp[l][i]) win=true; s+=v[i-1]; } } dp[l][r]=win; } } cout<<(dp[0][n]?"A":"B")<