# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
659089 | | kstew16 | 앱 (KOI13_app) | Kotlin (JVM) | | 192 ms | 18732 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
fun main():Unit = with(BufferedReader(InputStreamReader(System.`in`))){
val (n,m) = readLine().split(" ").map{it.toInt()}
var st = StringTokenizer(readLine())
val memoryArr = IntArray(n){st.nextToken().toInt()}
st = StringTokenizer(readLine())
val costArr = IntArray(n){st.nextToken().toInt()}
// dp[p][i] p번째 프로그램까지 실행해 봤을 때, i 의 재실행 비용을 통해 확보할 수 있는 최대 메모리
val dp = Array(n){IntArray(10001){0}}.apply{this[0][costArr[0]] = memoryArr[0]}
for(i in 1 until n){
val cost = costArr[i]
val memory = memoryArr[i]
for(j in 0 until 10001){
dp[i][j] = dp[i-1][j]
if(j-cost in 0 until 10001) dp[i][j] = (dp[i-1][j-cost] + memory).coerceAtLeast(dp[i][j])
}
}
for(j in 0 until 10001){
if(dp[n-1][j]>=m){
print(j)
break
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |