結果

問題 No.973 余興
ユーザー ytftytft
提出日時 2021-04-16 04:42:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,626 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 172,900 KB
実行使用メモリ 590,296 KB
最終ジャッジ日時 2023-09-15 07:04:07
合計ジャッジ時間 54,488 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 AC 513 ms
214,500 KB
testcase_12 AC 500 ms
214,668 KB
testcase_13 WA -
testcase_14 AC 509 ms
212,896 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 23 ms
17,948 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 38 ms
26,856 KB
testcase_23 AC 29 ms
22,368 KB
testcase_24 AC 29 ms
22,080 KB
testcase_25 AC 12 ms
11,784 KB
testcase_26 AC 22 ms
17,528 KB
testcase_27 AC 43 ms
30,740 KB
testcase_28 WA -
testcase_29 AC 29 ms
22,016 KB
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
testcase_33 MLE -
testcase_34 MLE -
testcase_35 MLE -
testcase_36 MLE -
testcase_37 MLE -
testcase_38 MLE -
testcase_39 MLE -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 WA -
testcase_46 MLE -
testcase_47 MLE -
testcase_48 MLE -
testcase_49 MLE -
testcase_50 MLE -
testcase_51 MLE -
testcase_52 MLE -
testcase_53 MLE -
testcase_54 MLE -
testcase_55 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,X;
    cin>>N>>X;
    vector<long long> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    vector<vector<long long>> dp(N,vector<long long>(N));
    vector<vector<long long>> sum(N,vector<long long>(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