結果

問題 No.139 交差点
ユーザー ducktailducktail
提出日時 2018-09-11 13:55:54
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 678 bytes
コンパイル時間 7,891 ms
コンパイル使用メモリ 169,412 KB
実行使用メモリ 8,796 KB
最終ジャッジ日時 2023-09-05 12:06:51
合計ジャッジ時間 9,433 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,184 KB
testcase_01 AC 3 ms
7,188 KB
testcase_02 AC 2 ms
7,260 KB
testcase_03 AC 3 ms
7,452 KB
testcase_04 AC 3 ms
7,804 KB
testcase_05 AC 4 ms
8,008 KB
testcase_06 AC 3 ms
7,400 KB
testcase_07 AC 3 ms
8,304 KB
testcase_08 AC 3 ms
7,748 KB
testcase_09 AC 4 ms
8,008 KB
testcase_10 AC 4 ms
8,456 KB
testcase_11 AC 3 ms
7,492 KB
testcase_12 AC 4 ms
8,532 KB
testcase_13 AC 2 ms
7,292 KB
testcase_14 AC 4 ms
7,932 KB
testcase_15 AC 4 ms
8,352 KB
testcase_16 AC 3 ms
7,240 KB
testcase_17 AC 3 ms
8,196 KB
testcase_18 AC 3 ms
7,972 KB
testcase_19 AC 4 ms
8,572 KB
testcase_20 AC 3 ms
7,544 KB
testcase_21 AC 2 ms
7,148 KB
testcase_22 AC 3 ms
7,188 KB
testcase_23 AC 4 ms
8,796 KB
testcase_24 AC 3 ms
7,256 KB
testcase_25 AC 4 ms
7,660 KB
testcase_26 AC 3 ms
7,580 KB
testcase_27 AC 2 ms
7,404 KB
testcase_28 AC 3 ms
7,360 KB
testcase_29 AC 3 ms
7,760 KB
testcase_30 AC 3 ms
8,136 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
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, l] <- f
  solve l <$> replicateM n f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [[Int]] -> Int
solve l = g . foldl' f (0, 0)
  where
    f (x, t) [xi, wi, ti] = let st = t + xi - x
                                (q, r) = st `divMod` ti
                            in if odd q
                               then (xi + wi, st + ti - r + wi)
                               else if ti - r >= wi
                                    then (xi + wi, st + wi)
                                    else (xi + wi, st + 2 * ti - r + wi)
    g (x, t) = t + l - x
0