标签:div present red lin alc enter namespace 提交 贪心
2
4
1 2 3 4
1
1
12 0
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { int T; cin>>T; while(T--) { int n; cin>>n; if(n==1) { cout<<0<<endl; continue; } int a[100005]; cin>>a[0]; int minx = a[0]; int index = 0; for(int i=1;i<n;i++) { cin>>a[i]; if(a[i]<minx) { minx = a[i]; index = i; } } long long int ans = 0; for(int i=0;i<n;i++) { if(i!=index) { ans+=minx+a[i]; } } cout<<ans<<endl; } }
贪心题
标签:div present red lin alc enter namespace 提交 贪心
原文地址:https://www.cnblogs.com/hao-tian/p/9080582.html