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])
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
14520 KB |
Output is correct |
2 |
Correct |
199 ms |
14364 KB |
Output is correct |
3 |
Correct |
211 ms |
14272 KB |
Output is correct |
4 |
Correct |
205 ms |
14252 KB |
Output is correct |
5 |
Correct |
207 ms |
14368 KB |
Output is correct |
6 |
Correct |
251 ms |
17216 KB |
Output is correct |
7 |
Correct |
271 ms |
18936 KB |
Output is correct |
8 |
Correct |
239 ms |
20472 KB |
Output is correct |
9 |
Correct |
269 ms |
20568 KB |
Output is correct |
10 |
Correct |
264 ms |
20320 KB |
Output is correct |
11 |
Correct |
209 ms |
14264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
14520 KB |
Output is correct |
2 |
Correct |
199 ms |
14364 KB |
Output is correct |
3 |
Correct |
211 ms |
14272 KB |
Output is correct |
4 |
Correct |
205 ms |
14252 KB |
Output is correct |
5 |
Correct |
207 ms |
14368 KB |
Output is correct |
6 |
Correct |
251 ms |
17216 KB |
Output is correct |
7 |
Correct |
271 ms |
18936 KB |
Output is correct |
8 |
Correct |
239 ms |
20472 KB |
Output is correct |
9 |
Correct |
269 ms |
20568 KB |
Output is correct |
10 |
Correct |
264 ms |
20320 KB |
Output is correct |
11 |
Correct |
209 ms |
14264 KB |
Output is correct |
12 |
Runtime error |
540 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |