結果

問題 No.1792 科学の甲子園
ユーザー yudedako
提出日時 2022-01-26 12:56:01
言語 Scala(Beta)
(3.6.2)
結果
AC  
実行時間 1,319 ms / 4,000 ms
コード長 680 bytes
コンパイル時間 13,538 ms
コンパイル使用メモリ 259,708 KB
実行使用メモリ 66,448 KB
最終ジャッジ日時 2024-11-26 17:58:17
合計ジャッジ時間 50,203 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.annotation.tailrec
import scala.io.StdIn.*
import scala.math.max
@main def main =
  val n = readLine().toInt
  val students = Array.fill(n){
    readLine().split(' ').map(_.toLong)
  }
  val maxScore = Array.tabulate(1 << 6) { pattern =>
    val subject = (0 until 6).filter { i => ((pattern >> i) & 1) == 1 }
    students.map { score => subject.map(score).product }.max
  }
  var result = 0L
  for patternN <- 0 until (1 << 12) do
    val pattern = Array.tabulate(4){i =>
      (0 until 6).map{j => if ((patternN >> (2 * j)) & 3) == i then 1 << j else 0}.sum
    }
    val current = pattern.map(maxScore).product
    result = max(result, current)
  println(result)
0