結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー Iruyan_ZakIruyan_Zak
提出日時 2020-09-30 18:52:49
言語 PHP
(8.3.4)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 12,164 KB
実行使用メモリ 22,020 KB
最終ジャッジ日時 2023-09-20 11:12:54
合計ジャッジ時間 2,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,232 KB
testcase_01 AC 7 ms
12,260 KB
testcase_02 AC 20 ms
17,892 KB
testcase_03 AC 9 ms
12,200 KB
testcase_04 AC 22 ms
19,956 KB
testcase_05 AC 9 ms
12,284 KB
testcase_06 AC 25 ms
22,008 KB
testcase_07 AC 17 ms
15,820 KB
testcase_08 AC 27 ms
21,916 KB
testcase_09 AC 17 ms
15,848 KB
testcase_10 AC 20 ms
17,888 KB
testcase_11 AC 27 ms
21,976 KB
testcase_12 AC 18 ms
15,836 KB
testcase_13 AC 18 ms
15,852 KB
testcase_14 AC 26 ms
22,020 KB
testcase_15 AC 22 ms
20,032 KB
testcase_16 AC 13 ms
13,792 KB
testcase_17 AC 8 ms
12,300 KB
testcase_18 AC 13 ms
13,800 KB
testcase_19 AC 16 ms
15,908 KB
testcase_20 AC 15 ms
15,900 KB
testcase_21 AC 17 ms
15,844 KB
testcase_22 AC 7 ms
12,292 KB
testcase_23 AC 7 ms
12,280 KB
testcase_24 AC 26 ms
21,976 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

fscanf(STDIN, "%d %d", $n, $d);  // 5 2
$ds = explode(" ", fgets(STDIN));  // [1, 2, 3, 1000]

// 相対距離 -> 座標の変換
$ds_ = [0];
foreach ($ds as $val) {
  $ds_[] = end($ds_) + $val;
} // [0, 1, 3, 6, 1006]

// ソーシャルディスタンスを取る
for ($i=1; $i < count($ds_); $i++) {
  if($ds_[$i] - $ds_[$i - 1] < $d) {
    $ds_[$i] = $ds_[$i - 1] + $d;
  }
}

echo implode(" ", $ds_), "\n";
0