結果
| 問題 | No.3757 Happy End |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-10-15 21:23:29 |
| 言語 | Haskell (9.14.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 52 ms / 2,000 ms |
| + 393µs | |
| コード長 | 1,091 bytes |
| 記録 | |
| コンパイル時間 | 8,991 ms |
| コンパイル使用メモリ | 201,088 KB |
| 実行使用メモリ | 27,392 KB |
| 最終ジャッジ日時 | 2026-10-15 21:23:46 |
| 合計ジャッジ時間 | 12,511 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
import Control.Monad
import Control.Monad.State.Strict
import Control.Applicative
import Data.Bool
import Data.Function
import Data.List
import Data.Ord
import Data.List.Split
-- import System.IO (hFlush, stdout)
import Debug.Trace
input = getLine :: IO String
ii = readLn :: IO Int
li = map read . words <$> getLine :: IO [Int]
printYn b = putStrLn $ bool "No" "Yes" b
pairwise :: [a] -> [(a, a)]
pairwise xs = zip xs (drop 1 xs)
windows :: Int -> [a] -> [[a]]
windows size xs
| length w < size = []
| otherwise = w : windows size (drop 1 xs)
where
w = take size xs
countIf f = length . filter f
minmax (x:xs)
= foldl' (\(mi, ma) x -> (min mi x, max ma x)) (x, x) xs
solve ('H':'A':'P':'P':'Y':cs) = 1 + solve cs
solve (_:cs) = solve cs
solve [] = 0
main :: IO ()
main = do
n <- ii
s <- input
let (a, b) = splitAt (n-5) s
let ans = (solve a) + diff b "HAPPY"
print ans
where
diff xs ys = countIf (\(x, y) -> x /= y) $ zip xs ys
norioc