Pagini recente » Cod sursa (job #376191) | Cod sursa (job #3189983) | Cod sursa (job #152462) | Cod sursa (job #569406) | Cod sursa (job #2797220)
#include <fstream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
ifstream cin("podm.in");
ofstream cout("podm.out");
int 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] ;
int 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;
}