백준 2003번
https://www.acmicpc.net/problem/2003
import java.io.*
import java.util.*
// input
private lateinit var br: BufferedReader
// variables
private var N = 0
private var M = 0
private lateinit var arr: IntArray
fun main() {
br = BufferedReader(InputStreamReader(System.`in`))
val bw = BufferedWriter(OutputStreamWriter(System.out))
input()
bw.write(solve())
bw.close()
} // End of main
private fun solve(): String {
val sb = StringBuilder()
var ans = 0
var sum = 0
var l = 0
for (i in 0 until N) {
sum += arr[i]
while (sum > M && l <= i) {
sum -= arr[l]
l++
}
if (sum == M) ans++
}
sb.append(ans)
return sb.toString()
} // End of solve
private fun input() {
StringTokenizer(br.readLine()).run {
N = nextToken().toInt()
M = nextToken().toInt()
}
arr = IntArray(N)
StringTokenizer(br.readLine()).run {
for (i in 0 until N) {
arr[i] = nextToken().toInt()
}
}
} // End of inpute().toLong()
} // End of input