結果
問題 | No.1708 Quality of Contest |
ユーザー | yudedako |
提出日時 | 2022-01-25 15:56:22 |
言語 | Scala(Beta) (3.4.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,811 bytes |
コンパイル時間 | 14,006 ms |
コンパイル使用メモリ | 259,072 KB |
実行使用メモリ | 116,352 KB |
最終ジャッジ日時 | 2023-08-22 10:18:33 |
合計ジャッジ時間 | 47,584 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 987 ms
62,808 KB |
testcase_01 | AC | 984 ms
62,612 KB |
testcase_02 | AC | 993 ms
63,024 KB |
testcase_03 | AC | 1,108 ms
63,376 KB |
testcase_04 | AC | 1,106 ms
63,080 KB |
testcase_05 | AC | 1,108 ms
63,328 KB |
testcase_06 | AC | 1,104 ms
63,128 KB |
testcase_07 | AC | 1,093 ms
63,564 KB |
testcase_08 | AC | 973 ms
62,688 KB |
testcase_09 | AC | 1,830 ms
99,928 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
ソースコード
import java.io.BufferedReader import scala.annotation.tailrec import scala.collection.mutable import scala.io.{Source, StdIn} import scala.io.StdIn.* inline def readLine()(using reader: BufferedReader): String = reader.readLine() @main def main = given reader: BufferedReader = Source.stdin.bufferedReader() val Array(n, m, x) = readLine().split(' ').map(_.toInt) val problem = Array.fill(n) { val Array(a, b) = readLine().split(' ').map(_.toInt) (a, b - 1) } val k = readLine().toInt val contestant = readLine().split(' ').map(_.toInt) val sortedWithQuality = (0 until n).sorted(Ordering.by[Int, Int](problem(_)._1).reverse).toArray var all = 0 var newGenre = 0 val useGenre = Array.fill(m){false} val useProblem = Array.fill(n){false} val contestantCount = Array.fill(n + 1){0} for c <- contestant do contestantCount(c) += 1 var rest = k.toLong - contestantCount(0) var result = 0L for i <- 1 to n do while newGenre < n && useGenre(problem(sortedWithQuality(newGenre))._2) do newGenre += 1 while all < n && useProblem(sortedWithQuality(all)) do all += 1 if newGenre == n then val h = sortedWithQuality(all) useProblem(h) = true result += problem(h)._1 * rest else if all == n then val h = sortedWithQuality(newGenre) useProblem(h) = true useGenre(problem(h)._2) = true result += (problem(h)._1 + x) * rest else val hi = sortedWithQuality(newGenre) val hj = sortedWithQuality(all) if problem(hi)._1 + x < problem(hj)._1 then useProblem(hj) = true result += problem(hj)._1 * rest else useProblem(hi) = true useGenre(problem(hi)._2) = true result += (problem(hi)._1 + x) * rest rest -= contestantCount(i) println(result)