Submission #107028

#TimeUsernameProblemLanguageResultExecution timeMemory
107028gs14004서울에서 경산까지 (KOI17_travel)Kotlin (JVM)
29 / 100
540 ms66560 KiB
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 } for (i in 0..(n-1)){ val (x1, w1, x2, w2) = readLine()!!.trim().split(" ").map{ it.toInt() } var nxt = Array(k + 1) { -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); } dp = nxt; } println(dp[k]) }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...