結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー iwotiwot
提出日時 2020-09-06 14:58:23
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 91,436 KB
実行使用メモリ 7,444 KB
最終ジャッジ日時 2023-09-04 09:50:55
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 27 ms
6,436 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 32 ms
7,116 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 38 ms
7,032 KB
testcase_07 AC 20 ms
6,984 KB
testcase_08 AC 39 ms
7,332 KB
testcase_09 AC 21 ms
5,916 KB
testcase_10 AC 27 ms
6,188 KB
testcase_11 AC 41 ms
7,324 KB
testcase_12 AC 22 ms
6,440 KB
testcase_13 AC 21 ms
5,900 KB
testcase_14 AC 37 ms
7,048 KB
testcase_15 AC 29 ms
6,308 KB
testcase_16 AC 13 ms
5,336 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 14 ms
4,396 KB
testcase_19 AC 20 ms
6,416 KB
testcase_20 AC 17 ms
5,864 KB
testcase_21 AC 21 ms
6,240 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 42 ms
7,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.conv;
import std.algorithm;

void main()
{
    auto immutable input = readln().split;
    auto immutable N = input[0].to!int;
    auto immutable D = input[1].to!int;
    auto immutable A = readln().split.map!(v => v.to!int).array;
    auto result = [0];
    auto prev_pos = 0;
    foreach (i; 1..N) {
        auto pos = A[i-1] + prev_pos;
        result ~= pos;
        prev_pos = pos;
        if (result[i] - result[i-1] < D) {
            result[i] = result[i-1] + D;
        }
    }
    writeln(result.map!(a => a.to!string).join(" "));
}
0