結果

問題 No.973 余興
ユーザー ytftytft
提出日時 2021-04-16 04:38:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,576 bytes
コンパイル時間 4,160 ms
コンパイル使用メモリ 171,764 KB
実行使用メモリ 297,264 KB
最終ジャッジ日時 2023-09-15 07:02:13
合計ジャッジ時間 46,688 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1,145 ms
297,060 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 1,135 ms
296,968 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,085 ms
285,540 KB
testcase_11 AC 360 ms
109,228 KB
testcase_12 AC 352 ms
109,484 KB
testcase_13 WA -
testcase_14 AC 348 ms
108,356 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 12 ms
10,732 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 25 ms
15,180 KB
testcase_23 RE -
testcase_24 AC 18 ms
12,812 KB
testcase_25 AC 7 ms
7,832 KB
testcase_26 AC 12 ms
10,596 KB
testcase_27 AC 31 ms
17,448 KB
testcase_28 WA -
testcase_29 AC 17 ms
12,996 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,384 ms
295,744 KB
testcase_35 AC 1,346 ms
296,932 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,365 ms
296,320 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,384 KB
testcase_42 AC 2 ms
4,384 KB
testcase_43 RE -
testcase_44 AC 1 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 1,135 ms
296,976 KB
testcase_47 WA -
testcase_48 AC 1,132 ms
296,980 KB
testcase_49 WA -
testcase_50 AC 1,119 ms
294,652 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,360 ms
291,876 KB
testcase_54 AC 1,406 ms
296,936 KB
testcase_55 AC 1,387 ms
296,876 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=0;p<N;p++){
        for(int i=0;i<N-p;i++){
            j=i+p;
            if(p>0 && (zero(i+1,j,i+right[i],j) || zero(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