We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@jiseung 님의 정답이에요! 👏👏👏
function solution(alp, cop, problems) { let [alpMax, copMax] = [0, 0]; for (const [alp_req, cop_req] of problems) { alpMax = alpMax > alp_req ? alpMax : alp_req; copMax = copMax > cop_req ? copMax : cop_req; } const dp = Array.from({ length: alpMax + 1 }, () => Array.from({ length: copMax + 1 }, () => Infinity), ); alp = alp < alpMax ? alp : alpMax; cop = cop < copMax ? cop : copMax; for (let a = 0; a < alp + 1; a++) { for (let c = 0; c < cop + 1; c++) { dp[a][c] = 0; } } for (let a = alp; a < alpMax + 1; a++) { for (let c = cop; c < copMax + 1; c++) { if (a < alpMax) dp[a + 1][c] = dp[a + 1][c] < dp[a][c] + 1 ? dp[a + 1][c] : dp[a][c] + 1; if (c < copMax) dp[a][c + 1] = dp[a][c + 1] < dp[a][c] + 1 ? dp[a][c + 1] : dp[a][c] + 1; for (const [alp_req, cop_req, alp_rwd, cop_rwd, cost] of problems) { if (a >= alp_req && c >= cop_req) { const na = alpMax < a + alp_rwd ? alpMax : a + alp_rwd; const nc = copMax < c + cop_rwd ? copMax : c + cop_rwd; dp[na][nc] = dp[na][nc] < dp[a][c] + cost ? dp[na][nc] : dp[a][c] + cost; } } } } return dp[alpMax][copMax]; }
{ "probId": "118668", "author": "jiseung", "lang": "JavaScript", "createdAt": 1679485614483 }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
@jiseung 님의 정답이에요! 👏👏👏
제출한 정답
풀이 데이터
The text was updated successfully, but these errors were encountered: