



import functools


def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ) ->       int:

						# Validation
						if not isinstance(lowercase_    ,   lowercase_    ) or not all(isinstance(lowercase_    ,   lowercase_    ) for day in days    ):
												raise ValueError("The parameter days should be a list of integers"    )

						if len(lowercase_    ) != 3 or not all(isinstance(lowercase_    ,   lowercase_    ) for cost in costs    ):
												raise ValueError("The parameter costs should be a list of three integers"    )

						if len(lowercase_    ) == 0:
												return 0

						if min(lowercase_    ) <= 0:
												raise ValueError("All days elements should be greater than 0"    )

						if max(lowercase_    ) >= 366:
												raise ValueError("All days elements should be less than 366"    )

						UpperCAmelCase         =     set(lowercase_    )

						@functools.cache
						def dynamic_programming(lowerCamelCase_    ) -> int:
												if index > 365:
																		return 0

												if index not in days_set:
																		return dynamic_programming(index + 1    )

												return min(
												    costs[0] + dynamic_programming(index + 1    )    ,   costs[1] + dynamic_programming(index + 7    )    ,   costs[2] + dynamic_programming(index + 30    )    ,   )

						return dynamic_programming(1    )


if __name__ == "__main__":
		import doctest

		doctest.testmod()








from __future__ import annotations

def    lowerCamelCase_(lowerCamelCase_    ) ->       int:
						UpperCAmelCase         =     len(lowerCamelCase_    ) // 2

						# choose the middle 3 elements
						UpperCAmelCase         =     lst[m - 1 : m + 2]

						# if middle element is peak
						if three[1] > three[0] and three[1] > three[2]:
												return three[1]

						# if increasing, recurse on right
						elif three[0] < three[2]:
												if len(lst[:m]    ) == 2:
																		m -= 1
												return peak(lst[m:]    )

						# decreasing
						else:
												if len(lst[:m]    ) == 2:
																		m += 1
												return peak(lst[:m]    )


if __name__ == "__main__":
		import doctest

		doctest.testmod()



