


'''simple docstring'''




from __future__ import annotations

import time
from collections.abc import Sequence
from random import randint

from matplotlib import pyplot as plt





def   _a		(lowercase__			:   Sequence[float]							,   lowercase__			:   int							,   lowercase__			:   int						)			->			tuple[int | None, int | None, float]:






     """simple docstring"""
     if not arr:
          return None, None, 0
     if low == high:
          return low, high, arr[low]

     __snake_case           =						(low + high) // 2
     __snake_case      ,       __snake_case      ,       __snake_case           =						max_subarray(lowercase__							,   lowercase__							,   lowercase__						)
     __snake_case      ,       __snake_case      ,       __snake_case           =						max_subarray(lowercase__							,   mid + 1							,   lowercase__						)
     __snake_case      ,       __snake_case      ,       __snake_case           =						max_cross_sum(lowercase__							,   lowercase__							,   lowercase__							,   lowercase__						)
     if left_sum >= right_sum and left_sum >= cross_sum:
          return left_low, left_high, left_sum
     elif right_sum >= left_sum and right_sum >= cross_sum:
          return right_low, right_high, right_sum
     return cross_left, cross_right, cross_sum





def   _a		(lowercase__			:   Sequence[float]							,   lowercase__			:   int							,   lowercase__			:   int							,   lowercase__			:   int						)			->			tuple[int, int, float]:






     """simple docstring"""
     __snake_case      ,       __snake_case           =						float('-inf'						), -1
     __snake_case      ,       __snake_case           =						float('-inf'						), -1

     __snake_case           =						0
     for i in range(lowercase__							,   low - 1							,   -1						):
          summ += arr[i]
          if summ > left_sum:
               __snake_case           =						summ
               __snake_case           =						i

     __snake_case           =						0
     for i in range(mid + 1							,   high + 1						):
          summ += arr[i]
          if summ > right_sum:
               __snake_case           =						summ
               __snake_case           =						i

     return max_left, max_right, (left_sum + right_sum)





def   _a		(lowercase__			:   int						)			->			float:






     """simple docstring"""
     __snake_case           =						[randint(1							,   lowercase__						) for _ in range(lowercase__						)]
     __snake_case           =						time.time()
     max_subarray(lowercase__							,   0							,   input_size - 1						)
     __snake_case           =						time.time()
     return end - start





def   _a		()			->			None:






     """simple docstring"""
     __snake_case           =						[1_0, 1_0_0, 1_0_0_0, 1_0_0_0_0, 5_0_0_0_0, 1_0_0_0_0_0, 2_0_0_0_0_0, 3_0_0_0_0_0, 4_0_0_0_0_0, 5_0_0_0_0_0]
     __snake_case           =						[time_max_subarray(lowercase__						) for input_size in input_sizes]
     print('No of Inputs\t\tTime Taken'						)
     for input_size, runtime in zip(lowercase__							,   lowercase__						):
          print(lowercase__							,   '\t\t'							,   lowercase__						)
     plt.plot(lowercase__							,   lowercase__						)
     plt.xlabel('Number of Inputs'						)
     plt.ylabel('Time taken in seconds'						)
     plt.show()


if __name__ == "__main__":
       from doctest import testmod

       testmod()










import functools


def 					_a							(					lowerCAmelCase    ,						lowerCAmelCase )->	int:

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

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

		if len(lowerCAmelCase ) == 0:
				return 0

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

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

		SCREAMING_SNAKE_CASE_					      =							set(lowerCAmelCase )

		@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()