結果

問題 No.586 ダブルブッキング
コンテスト
ユーザー tanson
提出日時 2025-10-25 05:04:28
言語 Standard ML
(MLton 20210117)
結果
RE  
実行時間 -
コード長 714 bytes
コンパイル時間 6,516 ms
コンパイル使用メモリ 689,404 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-10-25 05:04:35
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

fun readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)



val () =
    let
        val p1 = readInt ()
        val p2 = readInt ()
        val n = readInt ()
        val r_n = List.tabulate (n, fn _ => readInt ())

        fun findAns () =
            let
                fun findAnsAux nil _ = 0
                  | findAnsAux (h :: tl) used =
                    if Array.sub (used, h) = true then (p1 + p2) + findAnsAux tl used
                    else (Array.update (used, h, true); findAnsAux tl used)
            in
                findAnsAux r_n (Array.array (999, false))
            end

        val ans = findAns ()

    in
        print (Int.toString ans ^ "\n")  
    end
0