結果

問題 No.973 余興
ユーザー やむなくやむなく
提出日時 2020-01-17 22:25:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 240 ms / 4,000 ms
コード長 2,397 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 171,532 KB
実行使用メモリ 6,452 KB
最終ジャッジ日時 2023-09-08 04:18:10
合計ジャッジ時間 11,008 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 239 ms
6,284 KB
testcase_01 AC 234 ms
6,168 KB
testcase_02 AC 234 ms
6,156 KB
testcase_03 AC 237 ms
6,040 KB
testcase_04 AC 239 ms
6,152 KB
testcase_05 AC 233 ms
6,228 KB
testcase_06 AC 231 ms
6,452 KB
testcase_07 AC 240 ms
6,228 KB
testcase_08 AC 236 ms
6,100 KB
testcase_09 AC 240 ms
6,200 KB
testcase_10 AC 224 ms
6,040 KB
testcase_11 AC 59 ms
6,104 KB
testcase_12 AC 60 ms
6,056 KB
testcase_13 AC 58 ms
6,164 KB
testcase_14 AC 59 ms
6,104 KB
testcase_15 AC 12 ms
6,124 KB
testcase_16 AC 12 ms
6,172 KB
testcase_17 AC 8 ms
6,224 KB
testcase_18 AC 10 ms
6,224 KB
testcase_19 AC 11 ms
6,288 KB
testcase_20 AC 9 ms
6,160 KB
testcase_21 AC 12 ms
6,296 KB
testcase_22 AC 12 ms
6,152 KB
testcase_23 AC 11 ms
6,168 KB
testcase_24 AC 11 ms
6,120 KB
testcase_25 AC 7 ms
6,280 KB
testcase_26 AC 9 ms
6,168 KB
testcase_27 AC 14 ms
6,108 KB
testcase_28 AC 10 ms
6,232 KB
testcase_29 AC 10 ms
6,172 KB
testcase_30 AC 159 ms
6,244 KB
testcase_31 AC 157 ms
6,060 KB
testcase_32 AC 156 ms
6,108 KB
testcase_33 AC 157 ms
6,176 KB
testcase_34 AC 154 ms
6,036 KB
testcase_35 AC 160 ms
6,192 KB
testcase_36 AC 156 ms
6,100 KB
testcase_37 AC 156 ms
6,220 KB
testcase_38 AC 158 ms
6,048 KB
testcase_39 AC 160 ms
6,224 KB
testcase_40 AC 4 ms
6,120 KB
testcase_41 AC 3 ms
6,052 KB
testcase_42 AC 4 ms
6,228 KB
testcase_43 AC 3 ms
6,168 KB
testcase_44 AC 3 ms
6,096 KB
testcase_45 AC 4 ms
6,108 KB
testcase_46 AC 167 ms
6,104 KB
testcase_47 AC 168 ms
6,208 KB
testcase_48 AC 166 ms
6,160 KB
testcase_49 AC 153 ms
6,216 KB
testcase_50 AC 162 ms
6,108 KB
testcase_51 AC 168 ms
6,220 KB
testcase_52 AC 150 ms
6,280 KB
testcase_53 AC 146 ms
6,228 KB
testcase_54 AC 148 ms
6,176 KB
testcase_55 AC 148 ms
6,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//
// Created by yamunaku on 2020/01/17.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    ll x;
    cin >> x;
    vl a(n);
    rep(i, n) cin >> a[i];
    vi li(n + 1, 0), lj(n + 1, 0);
    li[n] = n, lj[n] = n;
    ll r = 0;
    int idx = 0;
    rep(i, n){
        while(idx < n){
            if(r + a[idx] > x) break;
            r += a[idx];
            idx++;
        }
        li[i] = idx;
        r -= a[i];
    }
    r = 0;
    idx = 0;
    per(i, n){
        while(idx < n){
            if(r + a[n - 1 - idx] > x) break;
            r += a[n - 1 - idx];
            idx++;
        }
        lj[n - 1 - i] = idx;
        r -= a[i];
    }
    vector<bitset<5001>> dp(5001, bitset<5001>());
    vi ci(n + 1, 0), cj(n + 1, 0);
    rep(i, n + 1){
        rep(j, n + 1){
            if(i + j >= n) dp[i][j] = true;
        }
    }
    per(i, n){
        per(j, n){
            if(i + j >= n) continue;
            repl(k, li[i] + 1, li[i + 1] + 1){
                if(!dp[k][j]) ci[j]--;
            }
            repl(k, lj[j] + 1, lj[j + 1] + 1){
                if(!dp[i][k]) cj[i]--;
            }
            if(ci[j] + cj[i] > 0) dp[i][j] = true;
            if(!dp[i][j]){
                ci[j]++;
                cj[i]++;
            }
        }
    }
//    rep(i, n + 1){
//        rep(j, n + 1){
//            if(dp[i][j]) cout << "1";
//            else cout << "0";
//        }
//        cout << endl;
//    }
    if(dp[0][0]) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}
0