Pagini recente » Cod sursa (job #3184908) | Cod sursa (job #3188180) | Cod sursa (job #1971893) | Cod sursa (job #2285501) | Cod sursa (job #2797221)
#include <fstream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
ifstream cin("podm.in");
ofstream cout("podm.out");
long long v[509] ;
/// cautam cel mai mare element mereu si il scoatem parantezandul
int cauta_max(int n)
{
int nmx = 2 ;
for(int f = 2 ; f < n ; f ++)
if(v[f] > v[nmx])nmx = f ;
return nmx ;
}
void scoate(int poz, int &n)
{
for(int f = poz ; f <= n ; f ++)
v[f] = v[f + 1] ;
n -- ;
}
int main()
{
int n ;
cin >> n ;
n ++ ;
for(int f = 1 ; f <= n ; f ++)
cin >> v[f] ;
long long rez = 0 ;
while(n > 2)
{
int poz = cauta_max(n) ;
rez += v[poz] * v[poz - 1] * v[poz + 1] ;
scoate(poz, n) ;
}
cout << rez ;
return 0;
}