結果

問題 No.871 かえるのうた
ユーザー nebukuro09nebukuro09
提出日時 2019-08-30 21:33:03
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 115,196 KB
実行使用メモリ 14,520 KB
最終ジャッジ日時 2023-09-04 02:33:15
合計ジャッジ時間 3,767 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
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 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 8 ms
5,088 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 63 ms
14,196 KB
testcase_15 AC 62 ms
14,068 KB
testcase_16 AC 67 ms
14,520 KB
testcase_17 AC 57 ms
13,344 KB
testcase_18 AC 11 ms
5,708 KB
testcase_19 WA -
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 25 ms
6,984 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 7 ms
4,856 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 23 ms
9,292 KB
testcase_30 AC 38 ms
12,100 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 33 ms
9,448 KB
testcase_33 WA -
testcase_34 AC 12 ms
5,724 KB
testcase_35 AC 31 ms
10,072 KB
testcase_36 AC 41 ms
13,024 KB
testcase_37 AC 27 ms
7,276 KB
testcase_38 AC 55 ms
13,120 KB
testcase_39 WA -
testcase_40 AC 20 ms
8,880 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 21 ms
8,128 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 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;

    auto B = n.iota.map!(i => tuple(X[i], A[i], i)).array;
    B.sort!"a[0] < b[0]";

    int idx = -1;
    foreach (i; 0..n) if (B[i][2] == k) idx = i;

    int ans = 1;
    long mx = B[idx][0] + B[idx][1];

    foreach (i; idx+1..n) {
        if (B[i][0] <= mx) {
            ans += 1;
            mx = max(mx, B[i][0] + B[i][1]);
        }
    }

    mx = B[idx][0] - B[idx][1];

    foreach_reverse (i; 0..idx) {
        if (B[i][0] >= mx) {
            ans += 1;
            mx = min(mx, B[i][0] - B[i][1]);
        }
    }

    ans.writeln;
}
0