結果

問題 No.216 FAC
コンテスト
ユーザー tanson
提出日時 2026-05-11 01:41:33
言語 Standard ML
(MLton 20241230)
コンパイル:
mlton_wrapper _filename_
実行:
./main
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,282 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,412 ms
コンパイル使用メモリ 704,944 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-11 01:41:47
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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


fun makeTable a_s b_s =
    let
         val table = Array.array (101, 0)

         fun makeTableAux () = ListPair.app (fn (a, b) =>
                                          let
                                              val old = Array.sub (table, b)
                                          in
                                              Array.update (table, b, old + a)
                                          end)
                                      (a_s, b_s)
    in
        (makeTableAux ();
         table)
    end


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

        val table = makeTable a_s b_s
        val (maxIndex, _) = Array.foldli
                                       (fn (i, score, (mi, ms)) =>
                                           if ms < score then (i, score)
                                           else (mi, ms))
                                       (0, Array.sub (table, 0))
                                       table

        val ans = if maxIndex = 0 then "YES"
                  else "NO"
    in
        print (ans ^ "\n")
    end
0