結果

問題 No.973 余興
ユーザー nebukuro09nebukuro09
提出日時 2020-01-17 22:36:59
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 1,623 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 103,084 KB
実行使用メモリ 44,700 KB
最終ジャッジ日時 2023-09-04 04:46:18
合計ジャッジ時間 47,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,267 ms
43,124 KB
testcase_01 AC 1,275 ms
44,596 KB
testcase_02 AC 1,267 ms
44,700 KB
testcase_03 AC 1,272 ms
43,140 KB
testcase_04 AC 1,277 ms
43,464 KB
testcase_05 WA -
testcase_06 AC 1,277 ms
43,960 KB
testcase_07 WA -
testcase_08 AC 1,268 ms
43,176 KB
testcase_09 AC 1,287 ms
43,396 KB
testcase_10 AC 1,226 ms
42,284 KB
testcase_11 AC 490 ms
14,668 KB
testcase_12 AC 489 ms
14,648 KB
testcase_13 WA -
testcase_14 AC 482 ms
14,732 KB
testcase_15 AC 44 ms
4,380 KB
testcase_16 AC 44 ms
4,380 KB
testcase_17 AC 27 ms
4,380 KB
testcase_18 AC 35 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 43 ms
4,380 KB
testcase_22 AC 43 ms
4,376 KB
testcase_23 AC 35 ms
4,376 KB
testcase_24 AC 34 ms
4,380 KB
testcase_25 AC 16 ms
4,380 KB
testcase_26 AC 26 ms
4,376 KB
testcase_27 AC 52 ms
4,384 KB
testcase_28 AC 35 ms
4,380 KB
testcase_29 AC 35 ms
4,380 KB
testcase_30 AC 1,332 ms
43,148 KB
testcase_31 AC 1,336 ms
43,424 KB
testcase_32 AC 1,334 ms
43,736 KB
testcase_33 AC 1,331 ms
44,124 KB
testcase_34 AC 1,324 ms
42,812 KB
testcase_35 AC 1,340 ms
43,460 KB
testcase_36 AC 1,318 ms
43,128 KB
testcase_37 AC 1,295 ms
43,448 KB
testcase_38 AC 1,324 ms
44,164 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 1,085 ms
43,908 KB
testcase_47 WA -
testcase_48 AC 1,085 ms
43,468 KB
testcase_49 AC 996 ms
42,916 KB
testcase_50 AC 1,081 ms
42,940 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,534 ms
42,984 KB
testcase_54 AC 1,563 ms
43,180 KB
testcase_55 AC 1,562 ms
43,952 KB
権限があれば一括ダウンロードができます

ソースコード

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);

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

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

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