baekjoon 20260217
This commit is contained in:
parent
0e715c9c81
commit
f03d11717b
15
code_study/Baekjoon/python/2863.py
Normal file
15
code_study/Baekjoon/python/2863.py
Normal file
@ -0,0 +1,15 @@
|
||||
a, b = map(int, input().split())
|
||||
c, d = map(int, input().split())
|
||||
|
||||
v = []
|
||||
v.append(a/c + b/d)
|
||||
v.append(c/d + a/b)
|
||||
v.append(d/b + c/a)
|
||||
v.append(b/a + d/c)
|
||||
|
||||
maxNum = max(v)
|
||||
|
||||
for i in range(4) :
|
||||
if maxNum == v[i] :
|
||||
print(i)
|
||||
break
|
||||
34
code_study/Baekjoon/swift/11049.swift
Normal file
34
code_study/Baekjoon/swift/11049.swift
Normal file
@ -0,0 +1,34 @@
|
||||
func solve() {
|
||||
guard let N = Int(readLine() ?? "") else { return }
|
||||
|
||||
var size: [(Int, Int)] = []
|
||||
for _ in 0..<N {
|
||||
guard let input = readLine(),
|
||||
let rc = input.split(separator: " ").compactMap({Int($0)}) as? [Int],
|
||||
let r = rc.first, let c = rc.last
|
||||
else { return }
|
||||
|
||||
size.append((r,c))
|
||||
}
|
||||
|
||||
var dp = Array(repeating: Array(repeating: 0, count: N), count: N)
|
||||
|
||||
for len in 2...N {
|
||||
for start in 0...(N - len) {
|
||||
let end = start + len - 1
|
||||
dp[start][end] = Int.max
|
||||
|
||||
for k in start..<end {
|
||||
let op_left = dp[start][k]
|
||||
let op_right = dp[k+1][end]
|
||||
let op_merge = size[start].0 * size[k].1 * size[end].1
|
||||
|
||||
dp[start][end] = min(dp[start][end], op_left + op_right + op_merge)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(dp[0][N-1])
|
||||
}
|
||||
|
||||
solve()
|
||||
Loading…
x
Reference in New Issue
Block a user