diff --git a/code_study/Baekjoon/swift/2506.swift b/code_study/Baekjoon/swift/2506.swift new file mode 100644 index 0000000..3709249 --- /dev/null +++ b/code_study/Baekjoon/swift/2506.swift @@ -0,0 +1,15 @@ +let N = Int(readLine()!) +var nums = (readLine()!).split(separator: " ").compactMap{Int($0)} + +var score = 0 +var ans = 0 +for n in nums { + if n==0 { + score = 0 + continue + } + score += 1 + ans += score +} + +print(ans)