結果

問題 No.143 豆
ユーザー tanson
提出日時 2025-07-10 21:46:18
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 494 bytes
コンパイル時間 3,801 ms
コンパイル使用メモリ 686,776 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-10 21:46:27
合計ジャッジ時間 5,018 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun int_string n =
    if 0 <= n
    then Int.toString n
    else "-" ^ Int.toString (abs n)

val () =
    let
        val k = readInt ()
        val n = readInt ()
        val f = readInt ()
        val a_s = List.tabulate (f, fn _ => readInt ())
        val sum = foldl (fn (x, acc) => x + acc) 0 a_s
        val ans = if sum <= k * n then k * n - sum else ~1
    in
        print (int_string ans)
    end
0