https://www.luogu.org/problem/show?pid=2637
把出价从小到大排序,然后从小到大枚举,把每个出价当做卖价,最后和ans比较即可
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ms(i,j) memset(i, j, sizeof i);
int n,m;
int a[1005];
int ans = 0;
int minv;
int main()
{
scanf("%d%d", &n ,&m);
for (int i=1;i<=m;i++)
{
scanf("%d", &a[i]);
}
sort(a+1, a+1+m);
for (int i=1;i<=m;i++)
{
int tot = a[i]*(m-i+1);
if(tot>ans) {ans = tot; minv = a[i];}
}
printf("%d %d\n", minv, ans);
system("pause");
return 0;
}