結果

問題 No.945 YKC饅頭
ユーザー LeonardoneLeonardone
提出日時 2019-12-11 00:03:58
言語 Haskell
(9.8.2)
結果
AC  
実行時間 1,872 ms / 2,000 ms
コード長 1,368 bytes
コンパイル時間 8,851 ms
コンパイル使用メモリ 163,200 KB
実行使用メモリ 209,696 KB
最終ジャッジ日時 2023-09-06 07:59:23
合計ジャッジ時間 43,110 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,472 KB
testcase_01 AC 3 ms
7,480 KB
testcase_02 AC 3 ms
8,072 KB
testcase_03 AC 6 ms
10,136 KB
testcase_04 AC 3 ms
7,776 KB
testcase_05 AC 3 ms
8,472 KB
testcase_06 AC 5 ms
9,532 KB
testcase_07 AC 5 ms
8,904 KB
testcase_08 AC 4 ms
7,824 KB
testcase_09 AC 4 ms
8,616 KB
testcase_10 AC 5 ms
9,080 KB
testcase_11 AC 3 ms
8,468 KB
testcase_12 AC 4 ms
8,852 KB
testcase_13 AC 5 ms
9,732 KB
testcase_14 AC 5 ms
9,768 KB
testcase_15 AC 4 ms
8,652 KB
testcase_16 AC 3 ms
8,104 KB
testcase_17 AC 5 ms
9,808 KB
testcase_18 AC 5 ms
9,144 KB
testcase_19 AC 3 ms
7,824 KB
testcase_20 AC 3 ms
7,928 KB
testcase_21 AC 3 ms
8,096 KB
testcase_22 AC 6 ms
10,472 KB
testcase_23 AC 6 ms
10,572 KB
testcase_24 AC 6 ms
10,308 KB
testcase_25 AC 6 ms
10,316 KB
testcase_26 AC 6 ms
10,300 KB
testcase_27 AC 3 ms
7,632 KB
testcase_28 AC 2 ms
7,572 KB
testcase_29 AC 3 ms
7,480 KB
testcase_30 AC 3 ms
7,424 KB
testcase_31 AC 52 ms
17,260 KB
testcase_32 AC 52 ms
20,304 KB
testcase_33 AC 283 ms
51,140 KB
testcase_34 AC 862 ms
118,120 KB
testcase_35 AC 1,503 ms
176,024 KB
testcase_36 AC 1,291 ms
168,644 KB
testcase_37 AC 1,123 ms
150,132 KB
testcase_38 AC 933 ms
123,420 KB
testcase_39 AC 162 ms
34,612 KB
testcase_40 AC 143 ms
30,560 KB
testcase_41 AC 62 ms
21,492 KB
testcase_42 AC 1,332 ms
170,680 KB
testcase_43 AC 1,103 ms
151,656 KB
testcase_44 AC 1,072 ms
129,680 KB
testcase_45 AC 1,543 ms
197,180 KB
testcase_46 AC 32 ms
16,172 KB
testcase_47 AC 862 ms
115,964 KB
testcase_48 AC 143 ms
35,368 KB
testcase_49 AC 302 ms
52,776 KB
testcase_50 AC 1,644 ms
202,260 KB
testcase_51 AC 1,842 ms
209,460 KB
testcase_52 AC 1,872 ms
209,696 KB
testcase_53 AC 1,782 ms
209,580 KB
testcase_54 AC 1,752 ms
209,516 KB
testcase_55 AC 1,803 ms
209,468 KB
testcase_56 AC 42 ms
22,252 KB
testcase_57 AC 22 ms
14,088 KB
testcase_58 AC 823 ms
124,844 KB
testcase_59 AC 1,022 ms
142,272 KB
testcase_60 AC 323 ms
61,976 KB
testcase_61 AC 882 ms
131,764 KB
testcase_62 AC 883 ms
131,616 KB
testcase_63 AC 23 ms
12,960 KB
testcase_64 AC 352 ms
63,300 KB
testcase_65 AC 283 ms
55,960 KB
testcase_66 AC 272 ms
55,204 KB
testcase_67 AC 555 ms
82,024 KB
testcase_68 AC 343 ms
61,304 KB
testcase_69 AC 93 ms
24,180 KB
testcase_70 AC 122 ms
33,400 KB
testcase_71 AC 133 ms
33,372 KB
testcase_72 AC 444 ms
73,500 KB
testcase_73 AC 1,023 ms
131,892 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

{-# LANGUAGE OverloadedStrings #-}
import Data.List (sort)
import Data.Maybe (fromJust)
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main = B.interact $ solve . (\(x:xs) -> (x, zip [0..] $ map parse xs)) . B.lines

readInt = fst . fromJust . B.readInt

parse = (\(a:b:c:_) -> ([readInt a, readInt b], B.head c) :: ([Int], Char)) . B.words

solve (ns, xs) = B.pack . unwords . map show $ (\(a,b,c) -> [a, b, c]) ans
    where
        n = readInt . head $ B.words ns
        ys = sort $ map (\e -> (head . fst $ snd e, e)) xs
        r = (n+1,(length xs, ([n,n], 'X')))
        (ans,_,_) = foldl f ((0,0,0), 1, S.empty) (ys ++ [r])
        f a@(c, i, s) y@(j, e)
            | i == j = (c, i, (S.insert e s))
            | otherwise = f (g a) y
        g (c@(yc, kc, cc), i, s) = (c2, i+1, s2)
            where
                h s = case S.minView s of
                        Just ((_, ([_, b], _)), t)
                            | b >= i -> s
                            | otherwise -> h t
                        _ -> s
                s2 = h s
                c2 = case S.lookupMin s2 of
                        Just (_, (_, 'Y')) -> (yc+1,kc,cc)
                        Just (_, (_, 'K')) -> (yc,kc+1,cc)
                        Just (_, (_, 'C')) -> (yc,kc,cc+1)
                        _ -> c
                
                    
0