baekjoon 20251213

This commit is contained in:
songyc macbook 2025-12-13 20:30:53 +09:00
parent 191ed33a88
commit e8636c6b99
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1 @@
print(' '.join(map(str,sorted(map(int,input().split())))))

View File

@ -0,0 +1,15 @@
export {};
const input = require("fs").readFileSync(0).toString().trim().split("\n");
const [N, K]: number[] = input[0].split(" ").map(Number);
let items: number[][] = Array.from({length: N}, (_, i) => input[i+1].split(" ").map(Number));
let dp: number[] = Array(K+1).fill(0);
for(let [w,v] of items) {
for(let k=K; k>=w; k--) {
dp[k] = Math.max(dp[k-w] + v, dp[k]);
}
}
console.log(dp[K]);