이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |