結果

問題 No.162 8020運動
ユーザー gigurururugigurururu
提出日時 2015-03-07 00:09:15
言語 Haskell
(9.8.2)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 782 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 181,168 KB
実行使用メモリ 11,832 KB
最終ジャッジ日時 2023-09-06 20:23:25
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,552 KB
testcase_01 AC 6 ms
10,628 KB
testcase_02 AC 12 ms
11,676 KB
testcase_03 AC 12 ms
11,628 KB
testcase_04 AC 12 ms
11,772 KB
testcase_05 AC 12 ms
11,596 KB
testcase_06 AC 12 ms
11,732 KB
testcase_07 AC 12 ms
11,648 KB
testcase_08 AC 9 ms
11,724 KB
testcase_09 AC 3 ms
7,608 KB
testcase_10 AC 12 ms
11,680 KB
testcase_11 AC 6 ms
10,532 KB
testcase_12 AC 3 ms
8,952 KB
testcase_13 AC 11 ms
11,544 KB
testcase_14 AC 2 ms
7,896 KB
testcase_15 AC 2 ms
8,056 KB
testcase_16 AC 5 ms
9,404 KB
testcase_17 AC 3 ms
8,340 KB
testcase_18 AC 12 ms
11,648 KB
testcase_19 AC 7 ms
11,520 KB
testcase_20 AC 12 ms
11,540 KB
testcase_21 AC 12 ms
11,800 KB
testcase_22 AC 7 ms
11,484 KB
testcase_23 AC 12 ms
11,832 KB
testcase_24 AC 12 ms
11,604 KB
testcase_25 AC 11 ms
11,620 KB
testcase_26 AC 2 ms
7,600 KB
testcase_27 AC 6 ms
11,048 KB
testcase_28 AC 12 ms
11,656 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 Control.Applicative
import Data.List
import Data.Array

repeated_combination ns n = comb n [(ns,[])]
  where
    comb 0 xs = [a|(_,a)<-xs]
    comb c xs = comb (c-1) $ concatMap f xs
    f (xs,ys) = [(as,ys++[a])|as@(a:_)<-tails xs]

main = do
  n <- (80-).read <$> getLine
  [a,b,c] <- map ((/100).read) . words <$> getLine
  let pa n m
        | m==0 || m==n+1 = 1
        | n==1 && m==1   = a
        | m==1 || m==n   = b
        | otherwise      = c
      sub nn m [i,j] = foldl (*) ((dp!(nn,(j-i+1)))*(pa m (i-1))*(pa m (j+1))) $ map ((1-).(pa m)) [i..j]
      calc 0  m = fromIntegral m
      calc nn m = foldl1 (+) $ map (sub (nn-1) m) $ repeated_combination [1..m] 2
      dp = array ((0,0),(n,14)) [((i,j),calc i j)|i<-[0..n],j<-[0..14]]
    in print $ (dp!(n,14))*2
0