0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-11 19:06:26 +00:00
OI-codes/Luogu/P2637/P2637.cpp

22 lines
428 B
C++
Raw Normal View History

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