結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2018-02-03 11:34:26 |
言語 | Haskell (9.10.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 519 bytes |
コンパイル時間 | 1,630 ms |
コンパイル使用メモリ | 171,648 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-11 15:19:38 |
合計ジャッジ時間 | 2,717 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 RE * 7 |
コンパイルメッセージ
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:10:83: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Data.List, 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." | 10 | ansi = map (\[x,y,z] -> if d>=y then x+y+z else max x z + d) (windows3 (init (tail gs))) | ^^^^ [2 of 2] Linking a.out
ソースコード
import Data.List main = do d <- readLn cs <- concat . words <$> getContents let gs = (map length . group) (replicate 14 'x' ++ cs ++ replicate 14 'x') ansh = let (_:h:_) = gs in h + d anst = let (_:t:_) = reverse gs in t + d ansi = map (\[x,y,z] -> if d>=y then x+y+z else max x z + d) (windows3 (init (tail gs))) print (if length gs == 1 then d else (maximum [ansh, anst, maximum ansi])) windows3 xs = [g | (i,g) <- zip [0..] (zipWith3 (\x y z -> [x,y,z]) xs (drop 1 xs) (drop 2 xs)), even i]