結果

問題 No.871 かえるのうた
ユーザー nebukuro09nebukuro09
提出日時 2019-08-30 21:47:48
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,213 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 108,216 KB
実行使用メモリ 20,576 KB
最終ジャッジ日時 2023-09-04 02:33:47
合計ジャッジ時間 3,625 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 10 ms
5,536 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 66 ms
16,580 KB
testcase_15 AC 65 ms
16,132 KB
testcase_16 AC 79 ms
20,576 KB
testcase_17 AC 61 ms
15,588 KB
testcase_18 AC 11 ms
5,688 KB
testcase_19 AC 67 ms
17,936 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 28 ms
7,704 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 7 ms
5,592 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 25 ms
8,616 KB
testcase_30 AC 47 ms
14,756 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 41 ms
11,260 KB
testcase_33 AC 53 ms
15,124 KB
testcase_34 AC 13 ms
5,784 KB
testcase_35 AC 34 ms
10,832 KB
testcase_36 AC 44 ms
13,968 KB
testcase_37 AC 32 ms
10,856 KB
testcase_38 AC 68 ms
18,164 KB
testcase_39 AC 64 ms
17,952 KB
testcase_40 AC 29 ms
12,240 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 29 ms
11,216 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 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 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 = -(10L^^18);
    long mn = 10L^^18;

    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