baekjoon 20251227

This commit is contained in:
songyc macbook 2025-12-27 22:28:59 +09:00
parent 8e78f3629e
commit 8057e3788c
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,2 @@
time = sum([int(input()) for _ in range(4)])
print('\n'.join(list(map(str, [time//60, time%60]))))

View File

@ -0,0 +1,20 @@
export {};
const input = require("fs").readFileSync(0).toString().trim().split("\n");
const [C, N]: number[] = input[0].split(" ").map(Number);
let dp: number[] = Array(C+101).fill(Infinity);
dp[0] = 0;
for(let n = 1; n<=N; n++) {
const [cost, man]: number[] = input[n].split(" ").map(Number);
for(let i=man; i<C+101; i++) {
if(dp[i-man] !== Infinity) {
dp[i] = Math.min(dp[i], dp[i-man] + cost);
}
}
}
let ans: number = dp[C];
for(let i=1; i<=100; i++) ans = Math.min(ans, dp[C+i]);
console.log(ans);