아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Take a break!

면접 대비

시간 제한1초메모리 제한1024 MB

요약
작업을 한 시간 휴식으로 나뉜 연속 묶음으로 배열해 각 묶음의 배증 벌점과 난이도의 곱의 합을 최소화하고 휴식 시간까지 더한다.
난이도

보통10점 중 6점

유형
그리디, 정렬, 수학, 동적 계획법
정답자
아직 제출이 없습니다

문제

Some call you lazy, others (yourself included) call you a break optimizer.

You have been tasked with a large number of chores around your house. The tasks vary greatly in difficulty---some literally only take a second, like putting a fork the dishwasher; others require a lot more effort, like cleaning the drain.

Each task has a difficulty, which is the number of seconds it takes you to complete the task when you are fully rested. Whenever you complete a task and directly start another, its completion time doubles. Formally, completing a task with difficulty dd after ii tasks before it, without any intervening breaks, takes d⋅2id \cdot 2^i seconds.

However, whenever you take a solid break of at least one hour, you become fully rested. (Shorter breaks don’t do anything for you.)

For instance, here are two (suboptimal) ways of scheduling the four tasks in sample 33:

In both schedules, task 3 takes 22⋅1000=40002^2\cdot 1000=4000 seconds.

You have to complete all tasks, in any order. You begin fully rested. What is the shortest time to complete all tasks, including breaks?

입력

The first line contains the number 1≤n≤100,0001 \leq n \leq 100\\,000 of tasks to complete. The second line consists of nn integers d_1,…,d_nd\_1, \ldots , d\_n, the difficulty of each task in seconds, where 1≤d_i≤28,8001 \leq d\_i \leq 28\\,800.

출력

Output a single integer, the minimal time in seconds it takes for you to complete all tasks, including your breaks.

예제5

  1. 예제 1

    입력
    2
    300 400
    
    예상 출력
    1000
    
  2. 예제 2

    입력
    3
    1000 1100 1000
    
    예상 출력
    7100
    
  3. 예제 3

    입력
    4
    1000 1100 1000 800
    
    예상 출력
    9300
    
  4. 예제 4

    입력
    12
    1 1 1 1 1 1 1 1 1 1 1 1
    
    예상 출력
    3726
    
  5. 예제 5

    입력
    13
    1 1 1 1 1 1 1 1 1 1 1 1 1
    
    예상 출력
    3790