baekjoon 20260305
This commit is contained in:
parent
7d3a8a3ec9
commit
dc49e2c906
37
code_study/Baekjoon/java/_12015.java
Normal file
37
code_study/Baekjoon/java/_12015.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class _12015 {
|
||||||
|
public static void main(String args[]) {
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
|
int N = sc.nextInt();
|
||||||
|
int[] A = new int[N];
|
||||||
|
for(int i=0; i<N; i++) A[i] = sc.nextInt();
|
||||||
|
|
||||||
|
sc.close();
|
||||||
|
|
||||||
|
int[] LIS = new int[N];
|
||||||
|
int len = 0;
|
||||||
|
LIS[len++] = A[0];
|
||||||
|
|
||||||
|
for(int i=1; i<N; i++) {
|
||||||
|
int num = A[i];
|
||||||
|
|
||||||
|
if(LIS[len-1] < num) LIS[len++] = num;
|
||||||
|
else {
|
||||||
|
int left = 0, right = len-1;
|
||||||
|
int mid = (left + right) / 2;
|
||||||
|
while(left < right) {
|
||||||
|
if(LIS[mid] < num) left = mid + 1;
|
||||||
|
else right = mid;
|
||||||
|
|
||||||
|
mid = (left + right) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
LIS[mid] = num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(len);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
code_study/Baekjoon/python/2712.py
Normal file
22
code_study/Baekjoon/python/2712.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import sys
|
||||||
|
input = sys.stdin.readline
|
||||||
|
|
||||||
|
def conv(s) :
|
||||||
|
num, unit = s.split()
|
||||||
|
num = float(num)
|
||||||
|
|
||||||
|
if unit == "kg" :
|
||||||
|
return f"{num * 2.2046:.4f} lb"
|
||||||
|
elif unit == "lb" :
|
||||||
|
return f"{num * 0.4536:.4f} kg"
|
||||||
|
elif unit == "l" :
|
||||||
|
return f"{num * 0.2642:.4f} g"
|
||||||
|
else :
|
||||||
|
return f"{num * 3.7854:.4f} l"
|
||||||
|
|
||||||
|
ans = []
|
||||||
|
|
||||||
|
for _ in range(int(input())) :
|
||||||
|
ans.append(conv(input()))
|
||||||
|
|
||||||
|
print("\n".join(ans))
|
||||||
22
code_study/Baekjoon/swift/11053.swift
Normal file
22
code_study/Baekjoon/swift/11053.swift
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
func solv() {
|
||||||
|
guard let N = Int(readLine() ?? ""),
|
||||||
|
let a = readLine()
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
let A = a.split(separator: " ").compactMap{Int($0)}
|
||||||
|
guard A.count == N else { return }
|
||||||
|
|
||||||
|
var dp = Array(repeating: 1, count: N)
|
||||||
|
|
||||||
|
for i in 0..<N {
|
||||||
|
for j in 0..<i {
|
||||||
|
if A[i] > A[j] {
|
||||||
|
dp[i] = max(dp[i], dp[j] + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print(dp.max)
|
||||||
|
}
|
||||||
|
|
||||||
|
solv()
|
||||||
Loading…
x
Reference in New Issue
Block a user