This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std; using ii = pair<int,int>;
using ll = long long; using ld = long double;
#define _(x) const x&
#define REP(i,a,b) for (auto i = (a); i <= (b); ++i)
#define ZIP(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define MP make_pair
#define mup(x,y) x = min(x,y)
#define Mup(x,y) x = max(x,y)
#define size(x) int((x).size())
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector<ll> d(n);
for (auto &x : d) cin >> x;
// sort(d.begin(),d.end());
if (n == 1) {
cout << 0;
}
else {
ll mn = 2e9;
REP(i,0,n-1) mup(mn,d[i]);
cout << (n-2)*mn + accumulate(d.begin(),d.end(),0LL);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |