結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-05-08 19:59:29
言語 Haskell
(9.8.2)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 7,211 ms
コンパイル使用メモリ 166,400 KB
実行使用メモリ 17,168 KB
最終ジャッジ日時 2023-09-08 14:50:33
合計ジャッジ時間 2,995 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,676 KB
testcase_01 AC 32 ms
17,132 KB
testcase_02 AC 3 ms
7,540 KB
testcase_03 AC 2 ms
7,648 KB
testcase_04 AC 3 ms
7,532 KB
testcase_05 AC 22 ms
17,036 KB
testcase_06 AC 3 ms
7,616 KB
testcase_07 AC 3 ms
7,640 KB
testcase_08 AC 2 ms
7,596 KB
testcase_09 AC 2 ms
7,556 KB
testcase_10 AC 2 ms
7,628 KB
testcase_11 AC 2 ms
7,600 KB
testcase_12 AC 2 ms
7,556 KB
testcase_13 AC 3 ms
7,672 KB
testcase_14 AC 22 ms
15,176 KB
testcase_15 AC 12 ms
13,112 KB
testcase_16 AC 22 ms
15,304 KB
testcase_17 AC 12 ms
12,972 KB
testcase_18 AC 22 ms
15,100 KB
testcase_19 AC 23 ms
14,732 KB
testcase_20 AC 32 ms
17,168 KB
testcase_21 AC 4 ms
8,668 KB
testcase_22 AC 12 ms
13,732 KB
testcase_23 AC 32 ms
16,800 KB
testcase_24 AC 33 ms
17,000 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 #

import qualified Data.ByteString.Lazy.Char8 as C
import qualified Data.IntMap.Strict as M
import Data.Maybe (fromJust)

unsafeReadInt :: C.ByteString -> Int
unsafeReadInt = fst . fromJust . C.readInt

-- Based on https://rosettacode.org/wiki/Averages/Mode#Haskell
maxMode :: [Int] -> Int
maxMode xs = fst $ M.findMax $ M.filter (== m) ctr
    where
        ctr = foldr (\x -> M.insertWith (+) x 1) M.empty xs
        m = maximum $ M.elems ctr

main :: IO ()
main = print . maxMode .
    map unsafeReadInt . tail . C.words =<< C.getContents
0