結果

問題 No.126 2基のエレベータ
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-02-20 16:35:54
言語 Haskell
(9.8.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 381 bytes
コンパイル時間 9,122 ms
コンパイル使用メモリ 166,720 KB
実行使用メモリ 7,208 KB
最終ジャッジ日時 2023-08-22 16:13:10
合計ジャッジ時間 10,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,100 KB
testcase_01 AC 3 ms
7,080 KB
testcase_02 AC 2 ms
6,920 KB
testcase_03 AC 3 ms
7,056 KB
testcase_04 AC 3 ms
7,148 KB
testcase_05 AC 2 ms
7,040 KB
testcase_06 AC 2 ms
7,092 KB
testcase_07 AC 3 ms
7,204 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 2 ms
6,992 KB
testcase_12 AC 3 ms
6,928 KB
testcase_13 AC 2 ms
6,960 KB
testcase_14 AC 2 ms
7,072 KB
testcase_15 AC 3 ms
7,068 KB
testcase_16 AC 3 ms
7,056 KB
testcase_17 AC 3 ms
7,036 KB
testcase_18 AC 3 ms
7,072 KB
testcase_19 AC 2 ms
7,092 KB
testcase_20 AC 3 ms
7,160 KB
testcase_21 AC 3 ms
7,088 KB
testcase_22 AC 3 ms
7,192 KB
testcase_23 AC 2 ms
7,100 KB
testcase_24 AC 3 ms
7,152 KB
testcase_25 AC 2 ms
7,040 KB
testcase_26 AC 3 ms
7,120 KB
testcase_27 AC 3 ms
7,084 KB
testcase_28 AC 3 ms
7,080 KB
testcase_29 AC 3 ms
7,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>))

solve :: Int -> Int -> Int -> Int
solve a b s
    | s == 1 || da < db = s + abs (s - a)
    | a == 0            = ans + 2
    | otherwise         = ans
    where
        da = abs (a - s)
        db = abs (b - s)
        ans = a + db + min da (s - 1)

main :: IO ()
main = do
    [a, b, s] <- map read . words <$> getLine
    print $ solve a b s
0