結果

問題 No.1 道のショートカット
ユーザー 鶴田浩之鶴田浩之
提出日時 2020-04-14 12:30:37
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 981 bytes
コンパイル時間 1,022 ms
コンパイル使用メモリ 12,024 KB
実行使用メモリ 12,304 KB
最終ジャッジ日時 2023-09-22 13:41:26
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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