0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-11 07:06:27 +00:00
OI-codes/Luogu/problem/P2637/P2637.cpp
2021-06-30 08:37:14 +08:00

22 lines
428 B
C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a[1005], ans = 0, sum = 0;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i];
}
sort(a, a + m);
for (int i = 0; i < m; i++) {
int now = a[i];
if (now * (m - i) > ans && m - i <= n) {
sum = now;
ans = now * (m - i);
}
}
cout << sum << ' ' << ans;
return 0;
}