baekjoon 20260417
This commit is contained in:
parent
e10b8d91c0
commit
9025f098c1
1
code_study/Baekjoon/python/2446.py
Normal file
1
code_study/Baekjoon/python/2446.py
Normal file
@ -0,0 +1 @@
|
||||
print("\n".join([" "*i + "*"*(2*N-1-2*i) if i < N else " "*(2*(N-i-1)+i) + "*"*(2*N-1-2*(2*(N-i-1)+i)) for N in [int(input())] for i in range(2*N-1)]))
|
||||
28
code_study/Baekjoon/ts/11049.ts
Normal file
28
code_study/Baekjoon/ts/11049.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { start } from "repl";
|
||||
|
||||
export {};
|
||||
const input = require("fs").readFileSync(0).toString().trim().split("\n");
|
||||
|
||||
const N: number = Number(input[0]);
|
||||
let rc: number[][] = []
|
||||
for(let i=1; i<=N; i++) rc.push(input[i].split(" ").map(Number));
|
||||
|
||||
let dp: number[][] = Array.from({length : N}, () => new Array(N).fill(0));
|
||||
|
||||
for(let len=2; len<=N; len++) {
|
||||
for(let start=0; start<=N-len; start++) {
|
||||
const end: number = start + len - 1;
|
||||
dp[start][end] = Number.MAX_VALUE;
|
||||
|
||||
|
||||
for(let k=start; k<end; k++) {
|
||||
const leftOp: number = dp[start][k];
|
||||
const rightOp: number = dp[k+1][end];
|
||||
const mergeOp: number = rc[start][0]*rc[k][1]*rc[end][1];
|
||||
|
||||
dp[start][end] = Math.min(dp[start][end], leftOp + rightOp + mergeOp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(dp[0][N-1]);
|
||||
Loading…
x
Reference in New Issue
Block a user