La dulce trampa de la vida - Langston Hughes
Resumen
"The Sweet Flypaper of Life" de Langston Hughes narra la historia de Sister Mary, una anciana y perspicaz mujer de Harlem que intenta guiar a su joven nieto, Rodney, a través de los desafíos de la vida. Rodney es un adolescente que ha dejado la escuela y se siente atraído por las calles y las tentaciones que estas ofrecen. A través de sus observaciones, monólogos internos y diálogos con Rodney y otros vecinos, Sister Mary comparte su profunda sabiduría sobre la existencia, la fe, el amor y la lucha por sobrevivir con dignidad en un entorno urbano complejo. Utiliza la metáfora de la "dulce trampa para moscas de la vida" para describir cómo las personas, a pesar de sus intentos de escapar o evadir los problemas, terminan inevitablemente atrapadas por la propia vida, que es al mismo tiempo dulce y amarga, pero de la que uno no puede ni quiere separarse del todo. La novela es un retrato íntimo de la vida afroamericana en Harlem, vista a través de los ojos de una matriarca que anhela que su nieto encuentre su camino sin perder su alma.
Secciones del Libro
Sección 1: La Llegada de Rodney y la Filosofía de Sister Mary
La historia comienza presentándonos a Sister Mary, una anciana sabia y espiritualmente fuerte que vive en Harlem. Su nieto, Rodney, un adolescente de dieciséis años, viene a vivir con ella. Rodney es un joven que ha abandonado la escuela y parece desorientado, con una tendencia a la indolencia y una fascinación por la vida callejera. Sister Mary lo observa con una mezcla de amor, preocupación y una aguda comprensión de los peligros que acechan a la juventud en su entorno. Desde el principio, Sister Mary comienza a impartirle a Rodney su particular filosofía de vida, basada en años de experiencia, fe inquebrantable y un pragmatismo profundo. Ella le habla de la importancia de la educación, el trabajo y de no dejarse seducir por las superficialidades, pero siempre desde una perspectiva de "no luchar contra la vida", sino de entenderla y fluir con ella, como una mosca que se posa en el papel matamoscas dulce y pegajoso, que aunque la atrapa, también le resulta irresistible.
She started working for two popular online delivery apps. She wants to cook a specific amount of meals, let's say $N$ meals, for each delivery app, every week. For each delivery app she can cook one kind of meal, one specific recipe. Let's say for the first delivery app she will cook recipe A, and for the second delivery app she will cook recipe B.
For each recipe, A and B, she knows the estimated time it takes to cook one meal ($t_A$ for recipe A, and $t_B$ for recipe B), and the estimated profit she gets from selling one meal ($p_A$ for recipe A, and $p_B$ for recipe B).
She is a bit old, so she knows her physical capabilities are limited. She can only cook for a total of $H$ hours every week.
She wants to maximize her total profit for the week, cooking $N$ meals for each delivery app.
Given the number of meals she needs to cook for each app ($N$), the cooking time per meal for each recipe ($t_A, t_B$), the profit per meal for each recipe ($p_A, p_B$), and the total hours she can cook ($H$), calculate the maximum total profit she can achieve.
If it's impossible for her to cook $N$ meals for each app within her time limit, return -1.
Input Format:
The input will be a single line containing 7 integers: $N$, $t_A$, $p_A$, $t_B$, $p_B$, $H$.
Output Format:
The output should be a single integer representing the maximum total profit, or -1 if it's impossible.
Constraints:
- $1 \le N \le 1000$
- $1 \le t_A, t_B \le 100$
- $1 \le p_A, p_B \le 1000$
- $1 \le H \le 100000$
Example 1:
Input:
10 2 10 3 15 50
Output:
250
Explanation 1:
N = 10 (meals for each app)
t_A = 2 (hours per meal for recipe A)
p_A = 10 (profit per meal for recipe A)
t_B = 3 (hours per meal for recipe B)
p_B = 15 (profit per meal for recipe B)
H = 50 (total hours available)
To cook 10 meals of recipe A, it takes 10 * 2 = 20 hours. Profit = 10 * 10 = 100.
To cook 10 meals of recipe B, it takes 10 * 3 = 30 hours. Profit = 10 * 15 = 150.
Total time needed = 20 + 30 = 50 hours.
Total profit = 100 + 150 = 250.
Since the total time needed (50 hours) is exactly within the available time (50 hours), the maximum profit is 250.
Example 2:
Input:
10 2 10 3 15 40
Output:
-1
Explanation 2:
N = 10 (meals for each app)
t_A = 2 (hours per meal for recipe A)
p_A = 10 (profit per meal for recipe A)
t_B = 3 (hours per meal for recipe B)
p_B = 15 (profit per meal for recipe B)
H = 40 (total hours available)
Total time needed to cook 10 meals of recipe A and 10 meals of recipe B is 50 hours (as calculated in Example 1).
Since the total time needed (50 hours) is greater than the available time (40 hours), it's impossible for her to cook all required meals. So, the output is -1.
def calculate_max_profit(N, t_A, p_A, t_B, p_B, H):
"""
Calculates the maximum total profit Sister Mary can achieve.
Args:
N: Number of meals to cook for each app.
t_A: Cooking time per meal for recipe A.
p_A: Profit per meal for recipe A.
t_B: Cooking time per meal for recipe B.
p_B: Profit per meal for recipe B.
H: Total hours Sister Mary can cook.
Returns:
The maximum total profit, or -1 if it's impossible.
"""
# Calculate total time required for N meals of recipe A
time_recipe_A = N * t_A
# Calculate total profit from N meals of recipe A
profit_recipe_A = N * p_A
# Calculate total time required for N meals of recipe B
time_recipe_B = N * t_B
# Calculate total profit from N meals of recipe B
profit_recipe_B = N * p_B
# Calculate the total time needed to cook N meals for each app
total_time_needed = time_recipe_A + time_recipe_B
# Check if the total time needed is within the available hours
if total_time_needed <= H:
# If yes, calculate the total profit
total_profit = profit_recipe_A + profit_recipe_B
return total_profit
else:
# If no, it's impossible
return -1
if __name__ == '__main__':
# Read the input values from a single line
N, t_A, p_A, t_B, p_B, H = map(int, input().split())
# Calculate and print the result
result = calculate_max_profit(N, t_A, p_A, t_B, p_B, H)
print(result)
