Submission #107034

# Submission time Handle Problem Language Result Execution time Memory
107034 2019-04-21T13:36:50 Z gs14004 None (KOI17_travel) Kotlin
29 / 100
497 ms 66560 KB
import kotlin.math.*
import java.util.*
import java.math.*

fun main(args : Array<String>) = with(Scanner(System.`in`)) {
	val (n, k) = readLine()!!.trim().split(" ").map{ it.toInt() } 
	var dp = Array(k + 1) { 0 } 
    var nxt = Array(k + 1) { -987654321 }
	for (i in 0..(n-1)){
		val (x1, w1, x2, w2) = readLine()!!.trim().split(" ").map{ it.toInt() } 
        for(j in 0..k) nxt[j] = -987654321;
		for(j in 0..k){
			if(j >= x1) nxt[j] = max(nxt[j], dp[j - x1] + w1);
			if(j >= x2) nxt[j] = max(nxt[j], dp[j - x2] + w2);
		}
        for(j in 0..k) dp[j] = nxt[j];
	}
	println(dp[k])
}
# Verdict Execution time Memory Grader output
1 Correct 204 ms 14156 KB Output is correct
2 Correct 200 ms 14208 KB Output is correct
3 Correct 214 ms 14544 KB Output is correct
4 Correct 208 ms 14344 KB Output is correct
5 Correct 210 ms 14604 KB Output is correct
6 Correct 219 ms 17516 KB Output is correct
7 Correct 221 ms 18960 KB Output is correct
8 Correct 247 ms 20348 KB Output is correct
9 Correct 249 ms 20160 KB Output is correct
10 Correct 227 ms 20176 KB Output is correct
11 Correct 208 ms 14288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 204 ms 14156 KB Output is correct
2 Correct 200 ms 14208 KB Output is correct
3 Correct 214 ms 14544 KB Output is correct
4 Correct 208 ms 14344 KB Output is correct
5 Correct 210 ms 14604 KB Output is correct
6 Correct 219 ms 17516 KB Output is correct
7 Correct 221 ms 18960 KB Output is correct
8 Correct 247 ms 20348 KB Output is correct
9 Correct 249 ms 20160 KB Output is correct
10 Correct 227 ms 20176 KB Output is correct
11 Correct 208 ms 14288 KB Output is correct
12 Runtime error 497 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Halted 0 ms 0 KB -