Logo
(追記) (追記ここまで)

34307번 - Purchasing Perishables 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB34191864.286%

문제

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 $N$ 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 $N$ 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 $N$ meals. For instance, if she is planning out 4ドル$ days and decides on an interval of 3ドル$ days, then she will purchase 3ドル$ meals on the first day, and 1ドル$ meal on the fourth day for a total of 4ドル$ 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 $N$ days, help Katie determine the optimal interval and the minimum budget she needs to allocate to purchasing meals for the next $N$ days, given she will only purchase food on regular intervals.

입력

The first line of input contains a single integer 1ドル \leq N \leq 10^5,ドル the number of days for which Katie has prices. The next line contains $N$ space-separated integers $p_1, p_2, \ldots, p_N$ (1ドル \leq p_i \leq 10^9$), where $p_i$ is the price of a meal on the $i^{\text{th}}$ day.

출력

The output should consist of a single integer, the minimum budget required to purchase $N$ meals for the next $N$ days.

제한

예제 입력 1

4
4 10 9 3

예제 출력 1

15

예제 입력 2

5
15 89 19 54 30

예제 출력 2

75

예제 입력 3

3
1000000000 1000000000 1000000000

예제 출력 3

3000000000

힌트

출처

School > CS@Mines > CS@Mines HSPC 2024 K번

  • 문제를 만든 사람: Nathan George
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /