baekjoon 20260129

This commit is contained in:
songyc macbook 2026-01-29 20:20:28 +09:00
parent 2c88249a7b
commit 20ad5fa44b
3 changed files with 65 additions and 0 deletions

View File

@ -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)

View File

@ -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))

View File

@ -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);