-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirport.cpp
49 lines (46 loc) · 956 Bytes
/
Airport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include <queue>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
priority_queue<int, vector<int>, greater<int>> seatmin;
priority_queue<int>seatmax;
for(int i = 0; i< m;i++)
{
int val;
cin>>val;
seatmin.push(val);
seatmax.push(val);
}
int maximum = 0;
int cnt = n;
while(true)
{
int top = seatmax.top();
seatmax.pop();
seatmax.push(top-1);
maximum += top;
cnt--;
if(cnt == 0) break;
}
int minimum = 0;
cnt=n;
while(true)
{
int top = seatmin.top();
seatmin.pop();
if(top>1) seatmin.push(top-1);
minimum += top;
cnt--;
if(cnt == 0) break;
}
cout<<maximum<<" "<<minimum;
return 0;
}