結果
| 問題 | No.545 ママの大事な二人の子供 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-03-30 18:52:20 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 388 bytes | 
| コンパイル時間 | 13,099 ms | 
| コンパイル使用メモリ | 171,208 KB | 
| 実行使用メモリ | 15,872 KB | 
| 最終ジャッジ日時 | 2024-11-15 22:48:59 | 
| 合計ジャッジ時間 | 50,468 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 TLE * 12 | 
コンパイルメッセージ
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
            
            
            
        