結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
|
提出日時 | 2016-06-10 01:06:29 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 353 bytes |
コンパイル時間 | 8,501 ms |
コンパイル使用メモリ | 175,744 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2025-01-03 01:15:14 |
合計ジャッジ時間 | 9,171 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:6:1: warning: [GHC-94817] [-Wtabs] Tab character found here, and in two further locations. Suggested fix: Please use spaces instead. | 6 | [n, d, k] <- return . map read . words =<< getLine | ^^^^^^^^ Main.hs:8:66: 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"." | 8 | putStrLn $ if null res then "-1" else unwords (map show (head res)) | ^^^^ [2 of 2] Linking a.out
ソースコード
solve :: [Integer] -> Integer -> [[Integer]] solve [] _ = [] solve xs lim = (map (init xs ++) (map return [last xs .. lim])) ++ map (++[lim]) (solve (init xs) (lim - 1)) main = do [n, d, k] <- return . map read . words =<< getLine let res = filter ((== d) . sum) $ solve [1..k] n putStrLn $ if null res then "-1" else unwords (map show (head res))