結果

問題 No.607 開通777年記念
ユーザー momen999momen999
提出日時 2019-03-23 17:52:29
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 747 bytes
コンパイル時間 7,555 ms
コンパイル使用メモリ 169,856 KB
実行使用メモリ 233,632 KB
最終ジャッジ日時 2024-09-23 03:42:30
合計ジャッジ時間 12,892 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,888 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1,226 ms
32,256 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 38 ms
10,368 KB
testcase_10 AC 5 ms
6,944 KB
testcase_11 TLE -
testcase_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: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