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,33 @@
fun solve(N: Int, S: Int, I: List<Int>): Int {
val D = ArrayDeque<Pair<Int, Int>>()
D.addLast(Pair(0, 0))
var cnt = 0
while (D.isNotEmpty()) {
val (now, accum) = D.removeLast()
if (now == N) {
if (accum == S) {
cnt += 1
}
continue
} else {
D.addLast(Pair(now + 1, accum)) // 안 더하기
D.addLast(Pair(now + 1, accum + I[now]))
}
}
if (S == 0) {
cnt -= 1;
}
return cnt
}
fun main() {
val (N, S) = readln().split(' ').map(String::toInt)
val I = readln().split(' ').map(String::toInt)
println(solve(N, S, I))
}