Pentru această operație este nevoie să te autentifici.
Cod sursă (job #445768)
Utilizator |
|
IP | ascuns |
---|---|---|---|
Problemă | Lanterna | Compilator | cpp | 0,35 kb |
Rundă | Arhiva de probleme | Status | evaluat |
Dată | 13 mar. 2019 18:20:56 | Scor | 10 |
#include <bits/stdc++.h>
using namespace std;
int n,x,y, a[100001];
long long s=0;
int main(){
ifstream cin("lanterna.in");
ofstream cout("lanterna.out");
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+n+1);
while (n>=4){
x=a[1]+a[2]*2+a[n];
y=a[1]*2+a[n-1]+a[n];
s=s+min(x,y);
n=n-2;
}
cout<<s+2;
return 0;
}