From 20ad5fa44bd164c477133907988b8f60443f3410 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Thu, 29 Jan 2026 20:20:28 +0900 Subject: [PATCH] baekjoon 20260129 --- code_study/Baekjoon/python/10775.py | 30 +++++++++++++++++++++++++++++ code_study/Baekjoon/python/14470.py | 10 ++++++++++ code_study/Baekjoon/ts/12015.ts | 25 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 code_study/Baekjoon/python/10775.py create mode 100644 code_study/Baekjoon/python/14470.py create mode 100644 code_study/Baekjoon/ts/12015.ts diff --git a/code_study/Baekjoon/python/10775.py b/code_study/Baekjoon/python/10775.py new file mode 100644 index 0000000..a4b5a3e --- /dev/null +++ b/code_study/Baekjoon/python/10775.py @@ -0,0 +1,30 @@ +import sys +input = sys.stdin.readline + +G, P = int(input()), int(input()) +ans = 0 +parents = [i for i in range(G+1)] + +def find(x) : + if x != parents[x] : + parents[x] = find(parents[x]) + return parents[x] + +def union(x, y) : + x = find(x) + y = find(y) + + parents[x] = y + + +for _ in range(P) : + g = int(input()) + gate = find(g) + + if gate==0 : + break + + union(gate, gate-1) + ans += 1 + +print(ans) \ No newline at end of file diff --git a/code_study/Baekjoon/python/14470.py b/code_study/Baekjoon/python/14470.py new file mode 100644 index 0000000..0895b01 --- /dev/null +++ b/code_study/Baekjoon/python/14470.py @@ -0,0 +1,10 @@ +A = int(input()) +B = int(input()) +C = int(input()) +D = int(input()) +E = int(input()) + +if A > 0 : + print((B-A)*E) +else : + print((abs(A)*C + D + B*E)) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/12015.ts b/code_study/Baekjoon/ts/12015.ts new file mode 100644 index 0000000..9196962 --- /dev/null +++ b/code_study/Baekjoon/ts/12015.ts @@ -0,0 +1,25 @@ +export {}; +const input = require("fs").readFileSync(0).toString().trim().split('\n'); +const N: number = Number(input[0]); +const A: number[] = input[1].split(" ").map(Number); + +let LIS: number[] = new Array(N).fill(0); +let last_idx: number = -1; +LIS[++last_idx] = A[0]; + +for(let a of A.slice(1)) { + if(LIS[last_idx] < a) LIS[++last_idx] = a; + else { + let [left, right]: number[] = [0, last_idx]; + let mid: number = Math.floor((left + right) / 2); + while(left < right) { + if(LIS[mid] < a) left = mid + 1; + else right = mid; + + mid = Math.floor((left + right) / 2); + } + LIS[mid] = a; + } +} + +console.log(last_idx+1); \ No newline at end of file