結果

問題 No.545 ママの大事な二人の子供
ユーザー momen999momen999
提出日時 2019-03-30 18:52:20
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 388 bytes
コンパイル時間 7,235 ms
コンパイル使用メモリ 172,160 KB
実行使用メモリ 14,756 KB
最終ジャッジ日時 2024-04-27 18:20:23
合計ジャッジ時間 14,190 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,756 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 6 ms
7,808 KB
testcase_14 AC 8 ms
7,936 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 13 ms
7,936 KB
testcase_17 AC 35 ms
7,936 KB
testcase_18 AC 578 ms
8,064 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:9:19: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
  |
9 |     left = f (k + head (head ab)) (tail ab)
  |                   ^^^^

Main.hs:9:25: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
  |
9 |     left = f (k + head (head ab)) (tail ab)
  |                         ^^^^

Main.hs:9:36: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
  |
9 |     left = f (k + head (head ab)) (tail ab)
  |                                    ^^^^

Main.hs:10:26: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
10 |     right = f (k - last (head ab)) (tail ab)
   |                          ^^^^

Main.hs:10:37: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead

ソースコード

diff #

import Control.Monad (replicateM)

solve :: [[Int]] -> Int
solve ab = minimum $ map abs $ f 0 ab

f :: Int -> [[Int]] -> [Int]
f k [] = [k]
f k ab = left ++ right where
    left = f (k + head (head ab)) (tail ab)
    right = f (k - last (head ab)) (tail ab)

main = do
    n <- readLn :: IO Int
    ab <- map (map read . words) <$> replicateM n getLine :: IO [[Int]]
    print $ solve ab
0