D: Anipero 2012 Anipero Summer Live, commonly known as Anipero, is the largest anime…
- User
D: Anipero 2012
Anipero Summer Live, commonly known as Anipero, is the largest anime song live event in Japan where various anime song artists gather. 2D, who loves anime songs, decided to go to Anipero this year as well as last year.
He has already purchased m of psyllium to enjoy Anipero. Psyllium is a stick that glows in a chemical reaction when folded. By shaking the psyllium in time with the rhythm, you can liven up the live performance and increase your satisfaction. All the psylliums he purchased this time have the following properties.
- The psyllium becomes darker as time passes after it is folded, and loses its light in 10 minutes.
- Very bright for 5 minutes after folding (hereinafter referred to as "level 2").
- It will be a little dark 5 minutes after folding (hereinafter referred to as "level 1").
- The speed at which light is lost does not change whether it is shaken or not.
2D decided to consider the following problems as to how satisfied he would be with this year's Anipero by properly using the limited psyllium depending on the song.
He anticipates n songs that will be played during the live. The length of each song is 5 minutes. n songs continue to flow, and the interval between songs can be considered as 0 minutes. The following three parameters are given to each song.
- Satisfaction that increases when only one level 2 is shaken for a certain song
- Satisfaction that increases when only one level 1 is shaken for a certain song
- Satisfaction increases when no song is shaken in a certain song
Shaking the glow stick does not necessarily increase satisfaction. If you shake it, it may disturb the atmosphere of the venue and reduce your satisfaction. The same can be said when not shaking.
Psyllium must be used according to the following rules.
- You can fold only when the song starts, and you can fold as many as you like at one time. The time it takes to fold the psyllium can be ignored.
- Up to 8 songs can be played at the same time in one song.
- When shaking multiple psylliums, calculate the satisfaction level to be added by the following formula.
- (Number of Level 1) x (Satisfaction per level 1) + (Number of Level 2) x (Satisfaction per Level 2)
- If no psyllium is shaken, only the satisfaction level when no one is shaken is added.
- Once you decide to shake the psyllium, you cannot change it until the end of one song.
- The psyllium can be left unshaken. Also, it is not necessary to use up all the psyllium.
2D had finished predicting the live song, but he was tired of it and didn't feel like solving the problem. Your job is to write a program for him that seeks the maximum satisfaction you're likely to get at this year's live concert. Input
Assistant
pythonn, m = map(int, input().split()) songs = [tuple(map(int, input().split())) for _ in range(n)] INF = float('-inf') # Initialize DP table: [prev_fold][remaining] = max_satisfaction prev_dp = [[INF] * (m + 1) for _ in range(9)] prev_dp[0][m] = 0 # Starting state for a, b, c in songs: current_dp = [[INF] * (m + 1) for _ in range(9)] for prev_p in range(9): for rem in range(m + 1): if prev_dp[prev_p][rem] == INF: continue max_curr = min(8 - prev_p, rem) for curr_p in range(max_curr + 1): new_rem = rem - curr_p if new_rem < 0: continue # Calculate satisfaction for this song use = prev_p * b + curr_p * a not_use = c sat = max(use, not_use) total = prev_dp[prev_p][rem] + sat # Update current_dp if current_dp[curr_p][new_rem] < total: current_dp[curr_p][new_rem] = total prev_dp = current_dp # Find the maximum satisfaction after all songs max_sat = INF for p in range(9): for r in range(m + 1): if prev_dp[p][r] > max_sat: max_sat = prev_dp[p][r] print(max_sat)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.