結果

問題 No.118 門松列(2)
ユーザー Michae'GonMichae'Gon
提出日時 2015-07-19 06:09:18
言語 Haskell
(9.8.2)
結果
AC  
実行時間 316 ms / 5,000 ms
コード長 493 bytes
コンパイル時間 8,345 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 25,472 KB
最終ジャッジ日時 2024-04-17 13:04:03
合計ジャッジ時間 11,382 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
8,448 KB
testcase_01 AC 303 ms
25,216 KB
testcase_02 AC 316 ms
24,192 KB
testcase_03 AC 301 ms
25,216 KB
testcase_04 AC 305 ms
24,320 KB
testcase_05 AC 309 ms
25,472 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 285 ms
23,168 KB
testcase_10 AC 56 ms
12,416 KB
testcase_11 AC 74 ms
13,952 KB
testcase_12 AC 39 ms
11,136 KB
testcase_13 AC 27 ms
9,856 KB
testcase_14 AC 290 ms
23,296 KB
testcase_15 AC 13 ms
8,192 KB
testcase_16 AC 149 ms
18,560 KB
testcase_17 AC 24 ms
9,344 KB
testcase_18 AC 74 ms
14,080 KB
testcase_19 AC 126 ms
16,384 KB
testcase_20 AC 130 ms
17,408 KB
testcase_21 AC 217 ms
22,272 KB
testcase_22 AC 58 ms
12,416 KB
testcase_23 AC 205 ms
22,272 KB
testcase_24 AC 80 ms
13,952 KB
testcase_25 AC 119 ms
17,024 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.List
import Control.Applicative
main = getLine >> getLine >>= print . solve . map read . words

solve :: [Integer] -> Integer
solve xs = calc x xs' `mod` 1000000007
    where
        (x : xs') = map genericLength . group . sort $ xs

calc :: Integer -> [Integer] -> Integer
calc x (y : z : []) = x * y * z
calc x (y : zs) = x * calc' y zs + calc y zs

calc' :: Integer -> [Integer] -> Integer
calc' x (y : []) = x * y
calc' x (y : ys) = sum ((*) <$> [x] <*> (y : ys)) + calc' y ys
0