Submission #1517678


Source Code Expand

import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, D = sc.nextInt
    var X = sc.nextInt
    var prev = Array.fill[Int](N)(sc.nextInt)
    for (idx <- 0 until D - 1) {
      val now = Array.fill[Int](N)(sc.nextInt)
      val DP = Array.tabulate[Int](X + 1)(x => x)
      for (i <- 0 until N) {
        for (j <- 0 to X - prev(i)) {
          DP(j + prev(i)) = math.max(DP(j + prev(i)), DP(j) + now(i))
        }
      }
      //println(DP.mkString(" "))
      for (i <- 0 until DP.size) {
        X = math.max(X, DP(i) + DP.size - 1 - i)
      }
      prev = now
    }
    println(X)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Submission Info

Submission Time
Task A - Invest Master
User goryudyuma
Language Scala (2.11.7)
Score 100
Code Size 761 Byte
Status AC
Exec Time 420 ms
Memory 30704 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 35
Set Name Test Cases
All 00_sample01.txt, 00_sample02.txt, 00_sample03.txt, 00_sample04.txt, 05_anti_greedy.txt, 10_rand_small00.txt, 10_rand_small01.txt, 10_rand_small02.txt, 10_rand_small03.txt, 10_rand_small04.txt, 10_rand_small05.txt, 10_rand_small06.txt, 10_rand_small07.txt, 10_rand_small08.txt, 10_rand_small09.txt, 20_rand_medium00.txt, 20_rand_medium01.txt, 20_rand_medium02.txt, 20_rand_medium03.txt, 20_rand_medium04.txt, 20_rand_medium05.txt, 20_rand_medium06.txt, 20_rand_medium07.txt, 20_rand_medium08.txt, 20_rand_medium09.txt, 30_rand_large00.txt, 30_rand_large01.txt, 30_rand_large02.txt, 30_rand_large03.txt, 30_rand_large04.txt, 30_rand_large05.txt, 30_rand_large06.txt, 30_rand_large07.txt, 30_rand_large08.txt, 30_rand_large09.txt
Case Name Status Exec Time Memory
00_sample01.txt AC 336 ms 25532 KB
00_sample02.txt AC 340 ms 25396 KB
00_sample03.txt AC 339 ms 25544 KB
00_sample04.txt AC 329 ms 25412 KB
05_anti_greedy.txt AC 331 ms 25268 KB
10_rand_small00.txt AC 336 ms 23752 KB
10_rand_small01.txt AC 332 ms 25404 KB
10_rand_small02.txt AC 332 ms 25520 KB
10_rand_small03.txt AC 332 ms 27424 KB
10_rand_small04.txt AC 335 ms 25540 KB
10_rand_small05.txt AC 340 ms 25256 KB
10_rand_small06.txt AC 333 ms 25532 KB
10_rand_small07.txt AC 334 ms 25260 KB
10_rand_small08.txt AC 331 ms 25408 KB
10_rand_small09.txt AC 343 ms 25404 KB
20_rand_medium00.txt AC 335 ms 25420 KB
20_rand_medium01.txt AC 334 ms 25412 KB
20_rand_medium02.txt AC 339 ms 25532 KB
20_rand_medium03.txt AC 331 ms 25140 KB
20_rand_medium04.txt AC 334 ms 25400 KB
20_rand_medium05.txt AC 347 ms 25288 KB
20_rand_medium06.txt AC 337 ms 25404 KB
20_rand_medium07.txt AC 330 ms 25392 KB
20_rand_medium08.txt AC 334 ms 25416 KB
20_rand_medium09.txt AC 345 ms 25524 KB
30_rand_large00.txt AC 348 ms 25436 KB
30_rand_large01.txt AC 420 ms 30704 KB
30_rand_large02.txt AC 371 ms 26844 KB
30_rand_large03.txt AC 341 ms 25300 KB
30_rand_large04.txt AC 417 ms 30616 KB
30_rand_large05.txt AC 361 ms 26324 KB
30_rand_large06.txt AC 344 ms 25536 KB
30_rand_large07.txt AC 357 ms 25396 KB
30_rand_large08.txt AC 375 ms 26836 KB
30_rand_large09.txt AC 373 ms 26832 KB