結果
| 問題 | No.204 ゴールデン・ウィーク(2) |
| コンテスト | |
| ユーザー |
aimy
|
| 提出日時 | 2018-02-03 11:32:54 |
| 言語 | Haskell (9.10.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 487 bytes |
| コンパイル時間 | 1,578 ms |
| コンパイル使用メモリ | 172,416 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-11 15:19:35 |
| 合計ジャッジ時間 | 2,790 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 RE * 9 |
コンパイルメッセージ
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 (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]
aimy