結果

問題 No.607 開通777年記念
ユーザー momen999
提出日時 2019-03-23 17:52:29
言語 Haskell
(9.10.1)
結果
TLE  
実行時間 -
コード長 747 bytes
コンパイル時間 7,555 ms
コンパイル使用メモリ 169,856 KB
実行使用メモリ 233,632 KB
最終ジャッジ日時 2024-09-23 03:42:30
合計ジャッジ時間 12,892 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 1 -- * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:17:47: 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."
   |
17 |     | otherwise     = solve n (zipWith (+) a (head as)) (tail as)
   |                                               ^^^^

Main.hs:17:58: 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."
   |
17 |     | otherwise     = solve n (zipWith (+) a (head as)) (tail as)
   |                                                          ^^^^

Main.hs:22: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."
   |
22 |     putStrLn $ solve n (head as) (tail as)
   |                         ^^^^

Main.hs:22:35: 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."
   |
22 |     putStrLn $ solve n (head as) (tail as)
   |                                   ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad (replicateM)

f777 :: Int -> Int -> Int -> [Integer] -> Bool
f777 left right n xs
    | left == n = False
    | s == 777  = True
    | isIncR    = f777 left (right + 1) n xs
    | otherwise = f777 (left + 1) right n xs
    where
        s = sum $ take (right - left) $ drop left xs
        isIncR = left == right || (right /= n && s + xs !! right <= 777)

solve :: Int -> [Integer] -> [[Integer]] -> String
solve n a as
    | f777 0 1 n a  = "YES"
    | as == []      = "NO"
    | otherwise     = solve n (zipWith (+) a (head as)) (tail as)

main = do
    [n, m] <- map read . words <$> getLine :: IO [Int]
    as <- map (map read . words) <$> replicateM m getLine :: IO [[Integer]]
    putStrLn $ solve n (head as) (tail as)
0