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;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[500005],minn,maxx;
int main() {
cin>>n;
for(long long i=1;i<=n;i++) {
cin>>A[i];
}
if(n==1) { cout<<A[1]; return 0; }
if(n==2) { cout<<min(A[1]+A[1]+A[2],2*max(A[1],A[2])); return 0; }
if(n==3) {
a=A[1]+A[1]+A[2]+A[1]+A[2]+A[3];
b=2*max(A[1],A[2])+max(A[1],A[2])+A[3];
d=A[1]+2*(max(A[2],A[3])+A[1]);
c=3*max(A[1],max(A[2],A[3]));
cout<<min(min(a,b),min(c,d));
return 0;
}
cout<<A[1]*n;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |