Purchasing Perishables
시간 제한1초메모리 제한2048 MB
일별 식사 가격이 주어질 때, k일마다 장을 보고 그날 가격으로 k끼를 사서 N끼를 사는 총비용이 최소가 되는 k를 고른다.
문제
It's the beginning of a new semester at Mines, and Katie is planning out her grocery shopping for the foreseeable future. For each of the next days she needs ingredients for one meal. To inform her planning, she has compiled a list of prices the store is charging for a meal for each of the next days she wishes to plan out.
To keep her schedule orderly, Katie has decided to only go shopping on regular intervals. If there is a gap between shopping trips, she will buy exactly enough meals to last until her next purchase or until she has purchased all meals. For instance, if she is planning out days and decides on an interval of days, then she will purchase meals on the first day, and meal on the fourth day for a total of meals.
Katie has a lot of work to do for her Data Structures class and doesn't have time to figure out an optimal interval between shopping trips to minimize her shopping budget. Given the prices for the next days, help Katie determine the optimal interval and the minimum budget she needs to allocate to purchasing meals for the next days, given she will only purchase food on regular intervals.
입력
The first line of input contains a single integer , the number of days for which Katie has prices. The next line contains space-separated integers (), where is the price of a meal on the day.
출력
The output should consist of a single integer, the minimum budget required to purchase meals for the next days.