結果

問題 No.1 道のショートカット
ユーザー 鶴田浩之鶴田浩之
提出日時 2020-04-14 13:43:40
言語 PHP
(8.3.4)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 917 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 12,060 KB
実行使用メモリ 12,316 KB
最終ジャッジ日時 2023-09-27 22:27:07
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,272 KB
testcase_01 AC 6 ms
12,256 KB
testcase_02 AC 6 ms
12,200 KB
testcase_03 AC 6 ms
12,276 KB
testcase_04 AC 7 ms
12,304 KB
testcase_05 AC 7 ms
12,308 KB
testcase_06 AC 6 ms
12,256 KB
testcase_07 AC 7 ms
12,316 KB
testcase_08 AC 40 ms
12,252 KB
testcase_09 AC 14 ms
12,264 KB
testcase_10 AC 21 ms
12,200 KB
testcase_11 AC 7 ms
12,208 KB
testcase_12 AC 15 ms
12,216 KB
testcase_13 AC 15 ms
12,188 KB
testcase_14 AC 7 ms
12,204 KB
testcase_15 AC 6 ms
12,284 KB
testcase_16 AC 9 ms
12,228 KB
testcase_17 AC 7 ms
12,300 KB
testcase_18 AC 7 ms
12,304 KB
testcase_19 AC 6 ms
12,256 KB
testcase_20 AC 7 ms
12,184 KB
testcase_21 AC 6 ms
12,288 KB
testcase_22 AC 6 ms
12,184 KB
testcase_23 AC 25 ms
12,204 KB
testcase_24 AC 12 ms
12,292 KB
testcase_25 AC 7 ms
12,228 KB
testcase_26 AC 7 ms
12,264 KB
testcase_27 AC 19 ms
12,284 KB
testcase_28 AC 7 ms
12,256 KB
testcase_29 AC 17 ms
12,192 KB
testcase_30 AC 8 ms
12,216 KB
testcase_31 AC 7 ms
12,308 KB
testcase_32 AC 13 ms
12,272 KB
testcase_33 AC 9 ms
12,188 KB
testcase_34 AC 12 ms
12,180 KB
testcase_35 AC 7 ms
12,232 KB
testcase_36 AC 12 ms
12,284 KB
testcase_37 AC 14 ms
12,304 KB
testcase_38 AC 7 ms
12,288 KB
testcase_39 AC 8 ms
12,204 KB
testcase_40 AC 8 ms
12,304 KB
testcase_41 AC 7 ms
12,196 KB
testcase_42 AC 7 ms
12,208 KB
testcase_43 AC 6 ms
12,292 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$N = trim(fgets(STDIN));
$C = trim(fgets(STDIN));
$V = trim(fgets(STDIN));
$S = explode(" ",trim(fgets(STDIN)));
$T = explode(" ",trim(fgets(STDIN)));
$Y = explode(" ",trim(fgets(STDIN)));
$M = explode(" ",trim(fgets(STDIN)));

$ans = move (1, $C, 0, false);
if ($ans == false) {
  echo "-1\n";
} else {
  echo $ans."\n";
}


function move($start, $money, $time, $totalTime) {
  global $N, $V, $S, $T, $Y, $M;

  if ($money < 0) {
    return false;
  } else if ($start == $N) {
    return $time;
  } else if ($totalTime != false && $time >= $totalTime) {
    return false;
  }

  $min = $totalTime;
  for ($i = 0; $i < $V; $i++) {
    if ($start == $S[$i]) {
      $newTime = move($T[$i], $money - $Y[$i], $time + $M[$i], $min);
      if ($newTime == false) {

      } else if ($min == false) {
        $min = $newTime;
      } else {
        $min = min($min, $newTime);
      }
    }
  }

  return $min;
}

?>
0