贪心简单
2024-02-29 21:15:41
发布于:上海
5阅读
0回复
0点赞
这道题很简单,小小的贪心,每个都变成最小的那一项的个数
# include <iostream>
# include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int s[n];
long long pick = 0;
for (int i = 0; i < n; i ++) cin >> s[i];
int min_ele = *min_element(s, s + n);
for (int i = 0; i < n; i ++) pick += s[i] - min_ele;
cout << pick << endl;
return 0;
}
这里空空如也
有帮助,赞一个