-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAirport.cpp
More file actions
61 lines (59 loc) · 1 KB
/
Airport.cpp
File metadata and controls
61 lines (59 loc) · 1 KB
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<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m;
cin>>n>>m;
ll a[m],b[m];
for(ll i=0;i<m;i++)
{
cin>>a[i];
b[i]=a[i];
}
ll n1=n,n2=n;
sort(a,a+m,greater<ll>());
sort(b,b+m);
// for max
ll sum=0;
while(n1>0)
{
if(n1<=m)
{
for(ll i=0;i<n1;i++)
{
sum=sum+a[i];
}
n1=n1-m;
}
else
{
for(ll i=0;i<m;i++)
{
sum=sum+a[i];
a[i]=a[i]-1;
}
n1=n1-m;
}
}
// for min
ll SUM=0;
for(ll i=0;i<m;i++)
{
if(n2>0)
{
while(b[i]>0)
{
SUM=SUM+b[i];
b[i]=b[i]-1;
n2=n2-1;
}
}
else
break;
}
cout<<sum<<" "<<SUM<<endl;
return 0;
}