結果

問題 No.973 余興
ユーザー totori_nyaa
提出日時 2020-01-18 04:38:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,073 bytes
コンパイル時間 1,786 ms
コンパイル使用メモリ 174,832 KB
実行使用メモリ 816,308 KB
最終ジャッジ日時 2024-06-26 08:48:24
合計ジャッジ時間 8,340 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other MLE * 1 -- * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    
    int n,x;
    cin>>n>>x;
    ll a[n];
    ll sum[n+1]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum[i+1] += a[i] + sum[i];
    }
    bool dp[n][n] = {};
    set<int> st[n], ts[n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            st[i].insert(j);
            ts[i].insert(j);
        }
    }
    for(int i=n-1;i>=0;i--){
        for(int j=i+1;j<n;j++){
            int ret = *st[i].upper_bound(i);
            ll dif = sum[ret] - sum[i];
            bool pos = false;
            if(dif <= x) pos = 1;
            auto itr = ts[j].lower_bound(j);
            itr--;
            dif = sum[j+1] - sum[*itr];
            if(dif <= x) pos = 1;
            if(pos){
                dp[i][j] = 1;
                ts[j].erase(i);
                st[i].erase(j);
            }
        }
    }
    if(dp[0][n-1]){
        cout << "A\n";
    }
    else cout << "B\n";
}
0