結果

問題 No.973 余興
ユーザー shibh308shibh308
提出日時 2019-12-06 09:40:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,302 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 206,040 KB
実行使用メモリ 13,160 KB
最終ジャッジ日時 2024-05-10 02:01:03
合計ジャッジ時間 16,608 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 228 ms
13,160 KB
testcase_01 AC 232 ms
6,528 KB
testcase_02 AC 228 ms
6,656 KB
testcase_03 AC 252 ms
6,784 KB
testcase_04 AC 232 ms
6,656 KB
testcase_05 AC 228 ms
6,656 KB
testcase_06 AC 233 ms
6,528 KB
testcase_07 AC 235 ms
6,656 KB
testcase_08 AC 229 ms
6,528 KB
testcase_09 AC 231 ms
6,656 KB
testcase_10 AC 219 ms
6,656 KB
testcase_11 AC 1,257 ms
6,528 KB
testcase_12 AC 1,255 ms
6,528 KB
testcase_13 AC 1,234 ms
6,528 KB
testcase_14 AC 1,249 ms
6,400 KB
testcase_15 AC 13 ms
6,528 KB
testcase_16 AC 13 ms
6,656 KB
testcase_17 AC 9 ms
6,528 KB
testcase_18 AC 11 ms
6,528 KB
testcase_19 AC 11 ms
6,528 KB
testcase_20 AC 10 ms
6,656 KB
testcase_21 AC 13 ms
6,528 KB
testcase_22 AC 13 ms
6,400 KB
testcase_23 AC 12 ms
6,528 KB
testcase_24 AC 11 ms
6,528 KB
testcase_25 AC 7 ms
6,528 KB
testcase_26 AC 9 ms
6,656 KB
testcase_27 AC 14 ms
6,528 KB
testcase_28 AC 11 ms
6,528 KB
testcase_29 AC 11 ms
6,400 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

using i64 = long long;


signed main(){
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    int i, j, k, left, right;
    for(auto& w : v)
        cin >> w;

    vector<i64> r(n + 1, 0);
    for(i = 0; i < n; ++i)
        r[i + 1] = r[i] + v[i];

    array<int, 5000> nex, prev;
    for(i = 0; i < n; ++i){
        auto it = upper_bound(r.begin(), r.end(), r[i] + x);
        int idx = distance(r.begin(), it);
        nex[i] = min(idx, n);
        auto it2 = lower_bound(r.begin(), r.end(), r[i + 1] - x);
        idx = distance(r.begin(), it2);
        prev[i] = max(0, idx - 1);
    }

    bitset<25000000> a;

    for(k = 1; k < n; ++k)
        for(i = 0, j = k; j < n; ++i, ++j){
            bool f = false;
            for(right = max(i, prev[j]); right < j; ++right)
                if(!a[i * 5000 + right]){
                    f = true;
                    break;
                }
            int left_bound = min(nex[i], j + 1);
            if(!f)
                for(left = i + 1; left < left_bound; ++left)
                    if(!a[left * 5000 + j]){
                        f = true;
                        break;
                    }

            a.set(i * 5000 + j, f);
        }

    cout << (a[n - 1] ? "A" : "B") << endl;
}

0