結果

問題 No.116 門松列(1)
ユーザー かりあげクンかりあげクン
提出日時 2020-09-06 16:36:48
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 6,537 ms
コンパイル使用メモリ 180,448 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-06 21:12:23
合計ジャッジ時間 5,709 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 1 ms
6,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 1 ms
6,944 KB
testcase_20 WA -
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import           Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as BSC8

main :: IO ()
main = do
  BSC8.getLine
  xs <- map (fst . fromJust . BSC8.readInt) . BSC8.words <$> BSC8.getLine
  print $ countKadomatsu xs

countKadomatsu :: [Int] -> Int
countKadomatsu = para phi 0
  where
    phi x ([],        st) = st
    phi x ([y],       st) = st
    phi x ([y, z],    st) = st
    phi x ((p:q:r:_), st) = if p /= r && ((p > q && q < r) || (p < q && q > r))
                                then st + 1
                                else st

para :: (a -> ([a], b) -> b) -> b -> [a] -> b
para phi b = step
  where
    step [] = b
    step (x:xs) = phi x (xs, step xs)
0