結果

問題 No.607 開通777年記念
ユーザー momen999momen999
提出日時 2019-03-23 17:52:29
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 747 bytes
コンパイル時間 7,367 ms
コンパイル使用メモリ 165,056 KB
実行使用メモリ 33,728 KB
最終ジャッジ日時 2023-10-24 11:22:15
合計ジャッジ時間 12,818 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,216 KB
testcase_01 AC 2 ms
5,204 KB
testcase_02 AC 2 ms
5,312 KB
testcase_03 AC 2 ms
5,184 KB
testcase_04 AC 3 ms
5,204 KB
testcase_05 AC 2 ms
5,196 KB
testcase_06 AC 2 ms
5,184 KB
testcase_07 AC 1,203 ms
33,728 KB
testcase_08 AC 2 ms
5,772 KB
testcase_09 AC 42 ms
11,960 KB
testcase_10 AC 5 ms
8,136 KB
testcase_11 TLE -
testcase_12 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[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