RE了,悬关,求求啦!
查看原帖
RE了,悬关,求求啦!
878013
_Supernova楼主2023/11/30 22:43
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxN = 1e5 + 5;
ll N, c[maxN], ans, dp[maxN], idx;
bool cmp(ll x, ll y) {
	return (x <= y);
}
int main(void) {
	scanf("%lld", &N);
	for (ll i = 1; i <= N; ++i) {
		scanf("%lld", &c[i]);
	}
	sort(c + 1, c + N + 1, cmp);
	for (ll i = 1; i <= N; ++i) {
		if (c[i] * (N - i + 1) > ans) {
			ans = c[i] * (N - i + 1);
			idx = c[i];
		}
	}
	printf("%lld %lld", ans, idx);
	return 0;
}
2023/11/30 22:43
加载中...