結果

問題 No.973 余興
ユーザー mugen_1337mugen_1337
提出日時 2021-04-14 17:07:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,488 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 205,736 KB
実行使用メモリ 199,092 KB
最終ジャッジ日時 2023-09-13 06:43:23
合計ジャッジ時間 27,243 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 736 ms
198,984 KB
testcase_01 AC 734 ms
198,936 KB
testcase_02 AC 730 ms
198,912 KB
testcase_03 AC 735 ms
198,860 KB
testcase_04 AC 730 ms
198,872 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 697 ms
191,216 KB
testcase_11 AC 195 ms
73,740 KB
testcase_12 AC 186 ms
73,764 KB
testcase_13 WA -
testcase_14 AC 187 ms
73,192 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 8 ms
7,992 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 13 ms
10,960 KB
testcase_23 AC 9 ms
9,360 KB
testcase_24 AC 9 ms
9,368 KB
testcase_25 AC 5 ms
5,848 KB
testcase_26 AC 7 ms
7,844 KB
testcase_27 AC 15 ms
12,216 KB
testcase_28 WA -
testcase_29 AC 10 ms
9,392 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 678 ms
198,132 KB
testcase_35 AC 687 ms
198,876 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 682 ms
198,340 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 661 ms
198,924 KB
testcase_47 WA -
testcase_48 AC 662 ms
198,864 KB
testcase_49 WA -
testcase_50 AC 654 ms
197,596 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 701 ms
195,440 KB
testcase_54 AC 722 ms
198,920 KB
testcase_55 AC 720 ms
198,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
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<<x<<' ';}cout<<endl;
#define mod 998244353
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}



signed main(){
    int n;ll x;cin>>n>>x;
    vector<ll> v(n);
    cin>>v;
    vector<int> t_l(n),t_r(n);// can take [i, t_l[i]], [t_r[i], i]
    
    vector<ll> s(n);
    s[0]=v[0];
    for(int i=1;i<n;i++) s[i]=s[i-1]+v[i];

    for(int i=0;i<n;i++){
        {
            ll offset=(i?s[i-1]:0);
            int r=lower_bound(ALL(s),offset+x+1)-begin(s);
            t_l[i]=r-1;
        }
        {   
            int l=0,r=i,res=i;
            while(l<r){
                int m=(l+r)/2;
                int sum=s[i]-(m?s[m-1]:0);
                if(sum<=x) r=m-1,res=m;
                else       l=m+1;
            }
            t_l[i]=res;
        }
    }


    vector<vector<int>> L(n+2,vector<int>(n+2,0)),R(n+2,vector<int>(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])<<endl;
    return 0;
}
0