結果
| 問題 | 
                            No.973 余興
                             | 
                    
| コンテスト | |
| ユーザー | 
                             totori_nyaa
                         | 
                    
| 提出日時 | 2020-01-18 04:44:42 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,033 bytes | 
| コンパイル時間 | 1,666 ms | 
| コンパイル使用メモリ | 173,628 KB | 
| 実行使用メモリ | 814,592 KB | 
| 最終ジャッジ日時 | 2024-06-26 08:59:02 | 
| 合計ジャッジ時間 | 7,506 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 2 | 
| other | MLE * 1 -- * 53 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<int> st[5000];
bool dp[5000][5000];
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];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            st[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 = st[j].lower_bound(j);
            itr--;
            dif = sum[j+1] - sum[*itr];
            if(dif <= x) pos = 1;
            if(pos){
                dp[i][j] = 1;
                st[i].erase(j);
                st[j].erase(i);
            }
        }
    }
    if(dp[0][n-1]){
        cout << "A\n";
    }
    else cout << "B\n";
}
            
            
            
        
            
totori_nyaa