結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,288 KB
testcase_01 AC 7 ms
12,252 KB
testcase_02 AC 20 ms
17,880 KB
testcase_03 AC 9 ms
12,180 KB
testcase_04 AC 23 ms
19,964 KB
testcase_05 AC 8 ms
12,252 KB
testcase_06 AC 25 ms
21,976 KB
testcase_07 AC 18 ms
15,844 KB
testcase_08 AC 28 ms
22,004 KB
testcase_09 AC 18 ms
15,836 KB
testcase_10 AC 20 ms
17,832 KB
testcase_11 AC 27 ms
22,028 KB
testcase_12 AC 18 ms
15,772 KB
testcase_13 AC 18 ms
15,836 KB
testcase_14 AC 26 ms
22,044 KB
testcase_15 AC 22 ms
19,908 KB
testcase_16 AC 14 ms
13,796 KB
testcase_17 AC 8 ms
12,256 KB
testcase_18 AC 13 ms
13,780 KB
testcase_19 AC 17 ms
15,772 KB
testcase_20 AC 16 ms
15,852 KB
testcase_21 AC 18 ms
15,824 KB
testcase_22 AC 7 ms
12,268 KB
testcase_23 AC 7 ms
12,224 KB
testcase_24 AC 26 ms
22,000 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