結果
問題 | No.545 ママの大事な二人の子供 |
ユーザー | momen999 |
提出日時 | 2019-03-30 18:52:20 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 388 bytes |
コンパイル時間 | 13,099 ms |
コンパイル使用メモリ | 171,208 KB |
実行使用メモリ | 15,872 KB |
最終ジャッジ日時 | 2024-11-15 22:48:59 |
合計ジャッジ時間 | 50,468 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
13,636 KB |
testcase_01 | AC | 2 ms
14,628 KB |
testcase_02 | AC | 1 ms
13,764 KB |
testcase_03 | AC | 2 ms
13,648 KB |
testcase_04 | AC | 2 ms
14,496 KB |
testcase_05 | AC | 1 ms
13,644 KB |
testcase_06 | AC | 2 ms
13,640 KB |
testcase_07 | AC | 1 ms
14,624 KB |
testcase_08 | AC | 1 ms
13,764 KB |
testcase_09 | AC | 2 ms
13,644 KB |
testcase_10 | AC | 2 ms
13,632 KB |
testcase_11 | AC | 2 ms
13,768 KB |
testcase_12 | AC | 4 ms
13,644 KB |
testcase_13 | AC | 6 ms
15,744 KB |
testcase_14 | AC | 9 ms
15,016 KB |
testcase_15 | AC | 2 ms
13,644 KB |
testcase_16 | AC | 13 ms
15,488 KB |
testcase_17 | AC | 38 ms
14,752 KB |
testcase_18 | AC | 609 ms
14,756 KB |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | AC | 1 ms
6,816 KB |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
コンパイルメッセージ
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
ソースコード
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