mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 01:18:47 +00:00
22 lines
428 B
C++
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;
|
|
}
|