結果

問題 No.126 2基のエレベータ
ユーザー papinianuspapinianus
提出日時 2017-02-01 11:52:56
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 18,588 KB
実行使用メモリ 19,048 KB
最終ジャッジ日時 2023-08-25 17:01:18
合計ジャッジ時間 3,354 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 15 ms
18,880 KB
testcase_03 AC 15 ms
18,744 KB
testcase_04 AC 15 ms
18,892 KB
testcase_05 AC 14 ms
18,912 KB
testcase_06 AC 15 ms
18,896 KB
testcase_07 WA -
testcase_08 AC 15 ms
18,908 KB
testcase_09 AC 15 ms
18,920 KB
testcase_10 AC 15 ms
18,896 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 14 ms
18,764 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 15 ms
18,928 KB
testcase_19 AC 15 ms
18,820 KB
testcase_20 WA -
testcase_21 AC 15 ms
18,884 KB
testcase_22 AC 14 ms
18,884 KB
testcase_23 AC 14 ms
18,844 KB
testcase_24 AC 14 ms
18,952 KB
testcase_25 AC 14 ms
18,876 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
list($a, $b, $s) = explode(" ", trim(fgets(STDIN)));

if(a_callable($a, $b, $s))
{
    echo cost($a, $s);
} else {
    $path1 = transit($b, $s, $a);
    $path2 = transit($b, $s, 1, $a);
    echo min($path1, $path2);
}
echo PHP_EOL;

function a_callable($a, $b, $s) {
    $patha = abs($s - $a);
    $pathb = abs($s - $b);
    if($path <= $pathb) {
        return true;
    }
    return false;
}

function cost($a, $s) {
    return abs($s - $a) + $s;
}

function transit($a, $s, $p, $pick = 0) {
    if($pick) {$pick = abs($pick - $a);}
    return abs($s - $a) + cost($s, $p) + $pick;
    // return abs($s - $a) + abs($s - $p) + $p;
}

0