DOJ logoDOJ
Problems
Recently added problemsSaved problemsWorkbooks
CategoriesDLCContestsGroupsTeamsBoard
Ranking
Solved Problem RankingStreak rankingDOJ Power ranking
Status
Call for TasksLoginRegister
DOJ logoDOJ

Community online judge with OI-style subtask scoring, Elo ratings, and Discord-backed certification.

Problems
ProblemsCategories
Community
ContestsRankingBoardNoticesHost an external contestGuide
Account
LoginRegisterJudge Status
Policy
Terms of ServiceDLC RulesPrivacyAPI documentationLanguage runtimesContest rank rewardsRating and performance
© 2026 DOJ
All rights reserved
Editorial

루미의 스트레스 해소하기

Back to problem

Editorial

  • DP 문제입니다. dp[t][s]dp[t][s]dp[t][s]를 ttt분이 지났고 체력을 sss 이하로 썼을 때 스트레스의 최솟값으로 둡니다.
  • 처음에는 취미를 하나도 하지 않은 경우로 채웁니다: dp[t][s]=A+tFdp[t][s] = A + tFdp[t][s]=A+tF.
  • ttt, sss를 111부터 늘려 가며, 각 취미(해소량 LLL, 소모 시간 HHH, 체력 소모량 MMM)에 대해 갱신합니다.
    • t≥H이고 이면 취미를 시작할 때의 체력은 이고, 이 값으로 를 구합니다.
dp[t][s]=max⁡(0, min⁡(dp[t][s], dp[t][s−1], dp[t−1][s]+F, dp[t−H][s−M]−Leff))dp[t][s] = \max(0,\ \min(dp[t][s],\ dp[t][s-1],\ dp[t-1][s] + F,\ dp[t-H][s-M] - L_{eff}))dp[t][s]=max(
  • 그 취미를 할 수 없으면 마지막 항만 빼고 갱신합니다.
dp[t][s]=max⁡(0, min⁡(dp[t][s], dp[t][s−1], dp[t−1][s]+F))dp[t][s] = \max(0,\ \min(dp[t][s],\ dp[t][s-1],\ dp[t-1][s] + F))dp[t][s]=max(0, min(dp[t][s
  • 같은 취미를 여러 번 할 수 있으므로 dp[t−H][s−M]dp[t-H][s-M]dp[t−H][s−M]은 같은 표의 값을 그대로 씁니다.
  • 답은 dp[B][C]dp[B][C]dp[B][C]입니다.
  • 주의할 점
    • 취미를 즐기지 않는 동안에는 11분마다 스트레스가 씩 오릅니다.
t \ge H
t≥H
s≥Ms \ge Ms≥M
C−(s−M)C - (s - M)C−(s−M)
LeffL_{eff}Leff​
0
,
 
min
(
d
p
[
t
]
[
s
]
,
 
d
p
[
t
]
[
s
−
1], dp[t−
1][s]+
F, dp[t−
H][s−
M]−
Leff​))
]
,
 
d
p
[
t
]
[
s
−
1], dp[t−
1][s]+
F))
1
FFF
  • E>100E > 100E>100이면 LeffL_{eff}Leff​가 음수가 됩니다. 음수를 양수로 나눈 결과는 언어마다 다르니 주의합시다. 지문의 LeffL_{eff}Leff​는 내림입니다.
  • 스트레스의 최솟값은 000입니다.
  • 시간복잡도는 O(NBC)\mathcal{O}(NBC)O(NBC), 공간복잡도는 O(BC)\mathcal{O}(BC)O(BC)입니다.