From 507cba2f3b913191ddd3e5dc78566256e1e59357 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Tue, 27 Jan 2026 20:55:03 +0900 Subject: [PATCH] baekjoon 20260127 --- code_study/Baekjoon/c/10808.c | 17 ++++++ code_study/Baekjoon/swift/1005_2.swift | 80 ++++++++++++++++++++++++++ code_study/Baekjoon/swift/7453.swift | 65 +++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 code_study/Baekjoon/c/10808.c create mode 100644 code_study/Baekjoon/swift/1005_2.swift create mode 100644 code_study/Baekjoon/swift/7453.swift diff --git a/code_study/Baekjoon/c/10808.c b/code_study/Baekjoon/c/10808.c new file mode 100644 index 0000000..772188b --- /dev/null +++ b/code_study/Baekjoon/c/10808.c @@ -0,0 +1,17 @@ +#include + +int count[26]; + +int main() { + char s[101]; + scanf("%s", s); + + int i=0; + while(s[i] !='\0') { + count[s[i++] - 'a']++; + } + + for(int j=0; j<26; j++) printf("%d ",count[j]); + + return 0; +} \ No newline at end of file diff --git a/code_study/Baekjoon/swift/1005_2.swift b/code_study/Baekjoon/swift/1005_2.swift new file mode 100644 index 0000000..941d00a --- /dev/null +++ b/code_study/Baekjoon/swift/1005_2.swift @@ -0,0 +1,80 @@ +import Foundation + +final class FileIO { + private let buffer:[UInt8] + private var index: Int = 0 + + init(fileHandle: FileHandle = FileHandle.standardInput) { + + buffer = Array(try! fileHandle.readToEnd()!) + [UInt8(0)] + } + + @inline(__always) private func read() -> UInt8 { + defer { index += 1 } + return buffer[index] + } + + @inline(__always) func readInt() -> Int { + var sum = 0 + var now = read() + var isPositive = true + + while now == 10 || now == 32 { now = read() } + if now == 45 { isPositive = false; now = read() } + + while now >= 48, now <= 57 { + sum = sum * 10 + Int(now-48) + now = read() + } + + return sum * (isPositive ? 1 : -1) + } +} + +let input = FileIO() +var ans: [String] = [] + +func solve() -> String { + let (N, K) = (input.readInt(), input.readInt()) + + var build_time: [Int] = [0] + for _ in 0.. Int { + if dp[n] == -1 { + var total_time = 0 + for prev in pre_build_info[n] { + total_time = max(total_time, build(prev)) + } + dp[n] = total_time + build_time[n] + } + + return dp[n] + } + + return String(build(W)) +} + +func main() { + let T = input.readInt() + + for _ in 0..) + + var (pAB, pCD) = (0, 0) + let (nAB, nCD) = (AB.count, CD.count) + var ans = 0 + + while pAB < nAB && pCD < nCD { + let (ab, cd) = (AB[pAB], CD[pCD]) + + if ab + cd > 0 { + pCD += 1 + } + else if ab + cd < 0 { + pAB += 1 + } + else { + var countAB = 0 + while pAB < nAB && ab == AB[pAB] { + pAB += 1 + countAB += 1 + } + + var countCD = 0 + while pCD < nCD && cd == CD[pCD] { + pCD += 1 + countCD += 1 + } + + ans += countAB * countCD + } + } + + print(ans) +} + +solve()