結果

問題 No.973 余興
ユーザー ytftytft
提出日時 2021-04-16 04:45:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,590 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 172,020 KB
実行使用メモリ 297,264 KB
最終ジャッジ日時 2023-09-15 07:06:07
合計ジャッジ時間 41,069 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,007 ms
296,984 KB
testcase_01 AC 1,012 ms
296,932 KB
testcase_02 AC 1,035 ms
296,868 KB
testcase_03 AC 1,020 ms
296,624 KB
testcase_04 AC 1,018 ms
297,264 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 949 ms
285,552 KB
testcase_11 AC 336 ms
109,248 KB
testcase_12 AC 336 ms
109,260 KB
testcase_13 WA -
testcase_14 AC 331 ms
108,360 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 13 ms
10,860 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 26 ms
15,184 KB
testcase_23 AC 21 ms
12,968 KB
testcase_24 AC 19 ms
12,988 KB
testcase_25 AC 7 ms
7,612 KB
testcase_26 AC 13 ms
10,652 KB
testcase_27 AC 30 ms
17,232 KB
testcase_28 WA -
testcase_29 AC 19 ms
12,980 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,182 ms
295,588 KB
testcase_35 AC 1,179 ms
296,940 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,167 ms
295,992 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 1,188 ms
296,932 KB
testcase_47 WA -
testcase_48 AC 1,183 ms
297,036 KB
testcase_49 WA -
testcase_50 AC 1,166 ms
294,680 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,133 ms
291,948 KB
testcase_54 AC 1,160 ms
297,008 KB
testcase_55 AC 1,175 ms
297,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,X;
    cin>>N>>X;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    vector<vector<int>> dp(N,vector<int>(N));
    vector<vector<int>> sum(N,vector<int>(N));
    auto zero=[sum](int a,int b,int c,int d){
        if(a>0 && b>0){
            return sum[c][d]+sum[a-1][b-1]-sum[a-1][d]-sum[c][b-1]<(c+1-a)*(d+1-b);
        }else if(a==0 && b>0){
            return sum[c][d]-sum[c][b-1]<(c+1-a)*(d+1-b);
        }else if(a>0 && b==0){
            return sum[c][d]-sum[a-1][d]<(c+1-a)*(d+1-b);
        }else{
            return sum[c][d]<(c+1-a)*(d+1-b);
        }
    };
    int pointer=0;
    vector<int> right(N),left(N,1);
    long long temp=a[0];
    for(int i=0;i<N;i++){
        while(pointer<N-1 && temp+a[pointer+1]<=X){
            ++pointer;
            temp+=a[pointer];
            left[pointer]=pointer+1-i;
        }
        right[i]=pointer-i+1;
        temp-=a[i];
    }
    int j;
    for(int p=1;p<N;p++){
        for(int i=0;i<N-p;i++){
            j=i+p;
            if(p>0 && (zero(i+1,j,min(i+right[i],j),j) || zero(i,max(i,j-left[j]),i,j-1))){
                dp[i][j]=1;
            }else{
                dp[i][j]=0;
            }
            if(i>0){
                sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j];
            }else if(j>0){
                sum[i][j]=sum[i][j-1]+dp[i][j];
            }else{
                sum[i][j]=dp[i][j];
            }
        }
    }
    if(dp[0][N-1]){
        cout<<'A'<<endl;
    }else{
        cout<<'B'<<endl;
    }
}
0