0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P2637 第一次,第二次,成交!

R52203856
This commit is contained in:
Baoshuo Ren 2021-06-30 08:37:14 +08:00 committed by Baoshuo Ren
parent e9d383c241
commit a42a218177
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,21 @@
#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;
}