From 3f90e25b13d57b07dedf3c1ce1f7afb84b5b2d81 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Tue, 3 Feb 2026 21:06:22 +0900 Subject: [PATCH] baekjoon 20260203 --- code_study/Baekjoon/swift/2506.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 code_study/Baekjoon/swift/2506.swift 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)