baekjoon 20260129
This commit is contained in:
parent
2c88249a7b
commit
20ad5fa44b
30
code_study/Baekjoon/python/10775.py
Normal file
30
code_study/Baekjoon/python/10775.py
Normal 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)
|
||||
10
code_study/Baekjoon/python/14470.py
Normal file
10
code_study/Baekjoon/python/14470.py
Normal 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))
|
||||
25
code_study/Baekjoon/ts/12015.ts
Normal file
25
code_study/Baekjoon/ts/12015.ts
Normal 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);
|
||||
Loading…
x
Reference in New Issue
Block a user