-
Notifications
You must be signed in to change notification settings - Fork 0
/
218B - Airport.cpp
61 lines (58 loc) · 1.19 KB
/
218B - 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
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define pr(x) //(cout << #x << ' ' << x << ' ')
#define prln(x) //(cout << #x << ' ' << x << endl)
//#define ll long long
void file()
{
freopen("in.txt", "r", stdin);
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
priority_queue<int, vector<int>, less<int> > ll;
priority_queue<int, vector<int>, greater<int> > ss;
int max_ans = 0, min_ans = 0;
int temp;
for (int i = 0; i < m; ++i){
scanf("%d", &temp);
ss.push(temp);
ll.push(temp);
}
int t = n;
while (t){
int t_val = ll.top();
max_ans += t_val;
t_val--;
ll.pop();
--t;
if (t_val != 0)
ll.push(t_val);
}
t = n;
while (t){
int t_val = ss.top();
prln(t_val);
ss.pop();
min_ans += t_val;
prln(min_ans);
t_val --;
--t;
if (t_val != 0)
ss.push(t_val);
}
printf("%d %d", max_ans, min_ans);
return 0;
}