RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00357

Akcija

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(1^{st}\) round, October \(17^{th}\), 2015

There is a promotional offer in a bookstore “Take 3, pay for the 2 more expensive ones”. So, each
customer who picks 3 books gets the cheapest one for free. Of course, the customer can take even
more books and, depending on the way the books are arranged into groups of three, get the cheapest
one in each group for free.

For example, let the prices of the books taken by the customer be: 10 3 2 4 6 4 9. If he arranges them
into groups: (10, 3, 2), (4, 6, 4) and (9), he will get the books priced 2 from the first group for free and
the book priced 4 from the second group. We can see that he won’t get anything for free from the third
group because it contains only one book.

The lady working in the bookstore is we\(ll-in\)tentioned and she always wants to lower the price for each
customer as much as possible. For given book prices, help the lady arrange the books into groups in
the best way possible, so that the total price the customer has to pay is minimal.

Please note: The lady doesn’t have to arrange the books into groups so that each group contains
exactly 3 books, but the number of books in a group needs to be between 1 and 3, inclusively.

제약

In test cases worth 50% of points, it will hold that \(N \le 2000\).

입력 형식

The first line of input contains the integer N (\(1 \le N \le 100\,000\)), the number of books the customer
bought.
Each of the following N lines contains a single integer Ci (\(1 \le Ci \le 100\,000\)), the price of each book.

출력 형식

The first and only line of output must contain the required minimal price.

예제 1
입력
4
3
2
3
2
출력
8
예제 2
입력
6
6
4
5
5
5
5
출력
21
설명

Clarification of the first example: The lady can put the books priced 3, 2, 2 in one group, and only
the book priced 3 in the other group, which is also the cheapest combination.
Clarification of the second example: The lady puts books priced 6, 4, 5 in one group, and 5, 5, 5 in
the other, which gives us the cheapest combination.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2015/2016 Contest 1

평가 및 의견

Akcija

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Akcija

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8