結果

問題 No.973 余興
ユーザー nebukuro09nebukuro09
提出日時 2020-01-17 22:45:20
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 1,550 bytes
コンパイル時間 787 ms
コンパイル使用メモリ 103,096 KB
実行使用メモリ 44,980 KB
最終ジャッジ日時 2023-09-04 04:47:19
合計ジャッジ時間 38,308 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,147 ms
43,380 KB
testcase_01 WA -
testcase_02 AC 1,145 ms
43,156 KB
testcase_03 AC 1,146 ms
43,404 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,148 ms
43,416 KB
testcase_07 WA -
testcase_08 AC 1,148 ms
43,692 KB
testcase_09 AC 1,155 ms
43,656 KB
testcase_10 AC 1,105 ms
43,148 KB
testcase_11 WA -
testcase_12 AC 383 ms
14,716 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 41 ms
4,380 KB
testcase_16 AC 42 ms
4,376 KB
testcase_17 AC 25 ms
4,376 KB
testcase_18 AC 33 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 41 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 48 ms
4,380 KB
testcase_28 AC 33 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 1,027 ms
44,700 KB
testcase_31 AC 1,021 ms
44,124 KB
testcase_32 AC 1,020 ms
44,720 KB
testcase_33 AC 1,021 ms
42,912 KB
testcase_34 AC 1,012 ms
43,160 KB
testcase_35 WA -
testcase_36 AC 988 ms
42,620 KB
testcase_37 AC 988 ms
43,856 KB
testcase_38 AC 1,019 ms
42,856 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 769 ms
44,168 KB
testcase_49 AC 708 ms
42,180 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,233 ms
43,720 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto X = s[1].to!long;
    auto A = readln.split.map!(to!long).array;

    auto B = new long[](N+1);
    foreach (i; 0..N) B[i+1] = B[i] + A[i];

    long sum(int l, int r) {
        if (r < l) return 0;
        return B[r+1] - B[l];
    }

    int calc_left(int l, int r) {
        int hi = r + 1;
        int lo = l;
        while (hi - lo > 1) {
            int mid = (hi + lo) / 2;
            if (sum(l, mid) <= X) lo = mid;
            else hi = mid;
        }
        return lo;
    }

    int calc_right(int l, int r) {
        int hi = r;
        int lo = l - 1;
        while (hi - lo > 1) {
            int mid = (hi + lo) / 2;
            if (sum(mid, r) <= X) hi = mid;
            else lo = mid;
        }
        return hi;
    }

    auto ans = new bool[][](N, N);
    auto minr = new int[](N);
    auto maxl = new int[](N);
    foreach (i; 0..N) minr[i] = maxl[i] = i;

    foreach (l; 0..N) foreach (r; l+1..N) {
        int nr = calc_right(l, r) - 1;
        if (nr <= minr[l]) {
            ans[l][r] = true;
        } else {
            minr[l] = r;
        }
        int nl = calc_left(l, r) + 1;
        if (nl >= maxl[r]) {
            ans[l][r] = true;
        } else {
            maxl[r] = l;
        }
    }

    writeln(ans[0][N-1] ? "A" : "B");
}
0