結果

問題 No.871 かえるのうた
ユーザー nebukuro09nebukuro09
提出日時 2019-08-30 21:43:19
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,206 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 108,128 KB
実行使用メモリ 20,108 KB
最終ジャッジ日時 2023-09-04 02:33:37
合計ジャッジ時間 3,798 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 68 ms
16,488 KB
testcase_16 AC 82 ms
19,640 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 70 ms
15,776 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 28 ms
7,888 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 6 ms
4,500 KB
testcase_27 WA -
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 51 ms
15,820 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 42 ms
12,332 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 46 ms
12,860 KB
testcase_37 AC 33 ms
10,604 KB
testcase_38 AC 69 ms
18,696 KB
testcase_39 AC 65 ms
18,332 KB
testcase_40 AC 30 ms
12,048 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 29 ms
11,964 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,380 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 k = s[1] - 1;
    auto X = readln.split.map!(to!long).array;
    auto A = readln.split.map!(to!long).array;

    DList!(Tuple!(long, long)) qmin;
    DList!(Tuple!(long, long)) qmax;
    foreach (i; 0..k) qmin.insertBack(tuple(X[i], A[i]));
    foreach (i; k+1..n) qmax.insertBack(tuple(X[i], A[i]));

    int ans = 0;
    DList!(Tuple!(long, long)) que;
    que.insertBack(tuple(X[k], A[k]));

    long mx = -1;
    long mn = 1L << 59;

    while (!que.empty) {
        ans += 1;
        auto t = que.front;
        que.removeFront;
        auto x = t[0];
        auto a = t[1];
        mx = max(mx, x + a);
        mn = min(mn, x - a);
        while (!qmin.empty && qmin.back[0] >= mn) {
            que.insertBack(qmin.back);
            qmin.removeBack;
        }
        while (!qmax.empty && qmax.front[0] <= mx) {
            que.insertBack(qmax.front);
            qmax.removeFront;
        }
    }

    ans.writeln;
}
0