結果

問題 No.29 パワーアップ
ユーザー tanson
提出日時 2025-08-20 03:30:09
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,152 bytes
コンパイル時間 5,266 ms
コンパイル使用メモリ 688,380 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-20 03:30:16
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

                           
fun findAns n items =
    let
        val itemTable = Array.array (11, 0)
    in
        (
          List.app
              (fn (a, b, c) =>
                   (
                     Array.update (itemTable, a, Array.sub (itemTable, a) + 1);
                     Array.update (itemTable, b, Array.sub (itemTable, b) + 1);
                     Array.update (itemTable, c, Array.sub (itemTable, c) + 1)
                   )
              )
              items;
          let
              val (bySame, remains) =
                  Array.foldl
                      (fn (n, (accSame, accRemains)) =>
                          (accSame + n div 2, accRemains + n mod 2))
                      (0, 0)
                      itemTable
          in
              bySame + remains div 4
          end
        )
    end

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

        val ans = findAns n items
    in
        print (Int.toString ans ^ "\n")
    end

0