0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 03:38:48 +00:00
OI-codes/Luogu/P2637/P2637.cpp

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;
}