here is a promotional offer in a bookstore "Take 3, pay for the 2 more expensive ones". So, each custon ho picks 33 books gets the cheapest one for free. Of course, the customer can take even more books epending on the way the books are arranged into groups of three, get the cheapest one in each group ree. or example, let the prices of the books taken by the customer be: 2,3,4,4,6,9,102,3,4,4,6,9,10. If he arran nem into the groups (10,3,2)(10,3,2), (4,6,4)(4,6,4) and (9)(9), he will get the book priced 22 from the first roup for free and the book priced 44 from the second group. We can see that he will not get anything ree from the third group because it contains only one book. he lady working in the bookstore is well-intentioned and she always wants to lower the price for each ustomer as much as possible. For given book prices, help the lady arrange the books into groups in the est way possible, so that the total price the customer has to pay is minimal. lease note: The lady doesn't have to arrange the books into groups so that each group contains exactl ooks, but the number of books in a group needs to be between 11 and 33, inclusively. nput he first line of input contains the integer NN (1
here is a promotional offer in a bookstore "Take 3, pay for the 2 more expensive ones". So, each custon ho picks 33 books gets the cheapest one for free. Of course, the customer can take even more books epending on the way the books are arranged into groups of three, get the cheapest one in each group ree. or example, let the prices of the books taken by the customer be: 2,3,4,4,6,9,102,3,4,4,6,9,10. If he arran nem into the groups (10,3,2)(10,3,2), (4,6,4)(4,6,4) and (9)(9), he will get the book priced 22 from the first roup for free and the book priced 44 from the second group. We can see that he will not get anything ree from the third group because it contains only one book. he lady working in the bookstore is well-intentioned and she always wants to lower the price for each ustomer as much as possible. For given book prices, help the lady arrange the books into groups in the est way possible, so that the total price the customer has to pay is minimal. lease note: The lady doesn't have to arrange the books into groups so that each group contains exactl ooks, but the number of books in a group needs to be between 11 and 33, inclusively. nput he first line of input contains the integer NN (1
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
In C please

Transcribed Image Text:C Program
There is a promotional offer in a bookstore "Take 3, pay for the 2 more expensive ones". So, each customer
who picks 33 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: 2,3,4,4,6,9,102,3,4,4,6,9,10. If he arranges
them into the groups (10,3,2)(10,3,2), (4,6,4)(4,6,4) and (9)(9), he will get the book priced 22 from the first
group for free and the book priced 44 from the second group. We can see that he will not get anything for
free from the third group because it contains only one book.
The lady working in the bookstore is well-intentioned 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 33
books, but the number of books in a group needs to be between 11 and 33, inclusively.
Input
The first line of input contains the integer NN (1<N<100 0001<N<100 000), the number of books the
customer bought. Each of the following NN lines contains a single integer CiCi (1sCis100 0001sCis100
000), the price of each book.
Output
The first and only line of output must contain the required minimal price.
Sample Input 1
Sample Output 1
4
8.
3
2
3
2
Sample Input 2
Sample Output 2
21
5
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education