Siz ushbu muammoni dinamik dasturlash yordamida hal qilishingiz mumkin. Bu erda Python-dagi dasturning misoli mavjud, u barcha uylarni bo'yash uchun eng kam xarajatni qaytaradi, xarajatlar matrisi berilgan: ``python def min_cost_painting(costs): if n = len(costs) if n == 0: return 0 # Dp = [[0 for _ in range]] for _ in range]] matrisini ishga tushiradi dp = [[0 for _ in range]] for _ in range]] n) # Matrisning birinchi satrini boshlang'ich xarajatlar dp[0] = xarajatlar[0] # Matrisning qolgan qismini to'ldiring for i in range, n): dp[i][0] = xarajatlar[i][0] + min[i][p] - 1[1], dp[i][0] - 1[2] dp
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence