結果

問題 No.561 東京と京都
ユーザー aimyaimy
提出日時 2017-08-25 23:01:12
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 4,741 ms
コンパイル使用メモリ 176,000 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 15:42:07
合計ジャッジ時間 3,379 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

data Here = Tokyo | Kyoto deriving Eq

main = do
  [n,d] <- map read . words <$> getLine :: IO [Int]
  tks <- map (map read . words) . lines <$> getContents
  print (tt Tokyo d (tks++[[0,0]]))

tt _ _ [] = 0
tt _ _ [[0,0]] = 0 
tt Tokyo d ([t1,k1]:tks@([t2,k2]:_))
  | (t1+t2) < (k1+k2-d) || (t1+t2) < (k1+t2-2*d) = (max t1 k1 - d) + tt Kyoto d tks
  | otherwise = t1 + tt Tokyo d tks
tt Kyoto d ([t1,k1]:tks@([t2,k2]:_))
  | (k1+k2) < (t1+t2-d) || (k1+k2) < (t1+k2-2*d) = (max t1 k1 - d) + tt Tokyo d tks
  | otherwise = k1 + tt Kyoto d tks
0