restructure zeta/** to storage/zeta/**

This commit is contained in:
2025-05-10 21:54:24 +09:00
parent 2886820691
commit 2f2e0759fd
407 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
import kotlin.math.min
fun List<Int>.toTriple(): Triple<Int, Int, Int> {
return Triple(this[0], this[1], this[2])
}
fun solve(N: Int, C: Array<Triple<Int, Int, Int>>): Int {
val T = Array<Triple<Int, Int, Int>>(N) { Triple(0, 0, 0) }
T[0] = C[0]
for (i in 1 until N) {
T[i] = Triple(
min(T[i - 1].second, T[i - 1].third) + C[i].first,
min(T[i - 1].first, T[i - 1].third) + C[i].second,
min(T[i - 1].first, T[i - 1].second) + C[i].third
)
}
return minOf(T[N - 1].first, T[N - 1].second, T[N - 1].third)
}
fun main() {
val N = readln().toInt()
val C = Array<Triple<Int, Int, Int>>(N) {
readln().split(' ').map { s: String ->
s.toInt()
}.toTriple()
}
println(solve(N, C))
}