結果

問題 No.1686 Geschenkt
コンテスト
ユーザー tanson
提出日時 2026-02-07 02:02:02
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 575 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,677 ms
コンパイル使用メモリ 708,236 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-02-07 02:02:12
合計ジャッジ時間 4,645 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

fun member x nil = false
  | member x (h::tl) =
    if x = h
    then true
    else member x tl


val () =
    let
        val n = readInt ()
        val a_s = List.tabulate (n, fn _ => readInt ())

        val ans = List.foldl (fn (a, acc) =>
                                 if member (a - 1) a_s then acc
                                 else a + acc)
                             0
                             a_s
    in
        print (Int.toString ans ^ "\n")
    end
0