結果

問題 No.1 道のショートカット
ユーザー 鶴田浩之鶴田浩之
提出日時 2020-04-14 12:36:47
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 1,063 ms
コンパイル使用メモリ 12,036 KB
実行使用メモリ 17,000 KB
最終ジャッジ日時 2023-09-22 13:41:49
合計ジャッジ時間 10,780 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 7 ms
12,264 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 7 ms
12,212 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$N = rtrim(fgets(STDIN));
$C = rtrim(fgets(STDIN));
$V = rtrim(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