結果

問題 No.607 開通777年記念
コンテスト
ユーザー momen999
提出日時 2019-03-23 17:52:29
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 747 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 927 ms
コンパイル使用メモリ 198,536 KB
実行使用メモリ 236,448 KB
最終ジャッジ日時 2026-04-11 08:58:43
合計ジャッジ時間 5,781 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 1 -- * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/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.Internal.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' 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.Internal.List):
    "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.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.Internal.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' 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.Internal.List):
    "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"."
   |
22 |     putStrLn $ solve n (head as) (tail as)
   |                                   ^^^^

[2 

ソースコード

diff #
raw source code

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