Ayush7614 / Daily-Coding-DS-ALGO-Practice

A open source project🚀 for bringing all interview💥💥 and competative📘 programming💥💥 question under one repo📐📐
https://daily-ds-algo.github.io/DS-Algo-Website/
MIT License
323 stars 474 forks source link

Airport #202

Open palakagarwal5230 opened 3 years ago

palakagarwal5230 commented 3 years ago

Problem: Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows:

it is up to a passenger to choose a plane to fly on; if the chosen plane has x (x > 0) empty seats at the given moment, then the ticket for such a plane costs x zlotys (units of Polish currency). The only ticket office of the airport already has a queue of n passengers in front of it. Lolek and Bolek have not stood in the queue yet, but they are already wondering what is the maximum and the minimum number of zlotys the airport administration can earn if all n passengers buy tickets according to the conditions of this offer?

The passengers buy tickets in turn, the first person in the queue goes first, then goes the second one, and so on up to n-th person.

Input The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of passengers in the queue and the number of planes in the airport, correspondingly. The next line contains m integers a1, a2, ..., am (1 ≤ ai ≤ 1000) — ai stands for the number of empty seats in the i-th plane before the ticket office starts selling tickets.

The numbers in the lines are separated by a space. It is guaranteed that there are at least n empty seats in total..

Output Print two integers — the maximum and the minimum number of zlotys that the airport administration can earn, correspondingly.

Programming language

palakagarwal5230 commented 3 years ago

I am a LGM-SOC'21 Participant and has opened this issue. I want to write c++ solution to it. This problem is from codeforces .

jayant766 commented 3 years ago

can you please assign it to me.

jayant766 commented 3 years ago

I can do this in C or C++ or pyhon.

Assign me plz. LGM_SOC