Pagini recente » Cod sursa (job #3266270) | Cod sursa (job #2882423) | Cod sursa (job #905416) | Cod sursa (job #2691081) | Cod sursa (job #3251542)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("file.in");
ofstream fout("file.out");
bool cmp(pair<int, int> &a, pair<int, int> &b)
{
if (a.second > b.second)
return a.second > b.second;
else if (a.second == b.second)
return a.first > b.first;
}
int main()
{
int n;
fin >> n;
int a[n + 1];
int x;
for (int i = 0; i <= n; i++)
{
fin >> a[i];
}
n++;
long long int cnt = 0;
while (n > 2)
{
int ma = -1e9;
int poz = 0;
for (int i = 1 ; i < n - 1; i++)
if (a[i] > ma ) {ma = a[i]; poz = i;}
//cout << a[poz - 1] << ' ' << a[poz] << " " << a[poz] << ' ' << a[poz + 1] << endl;
cnt += a[poz - 1] * a[poz] * a[poz + 1];
for (int j = poz; j + 1 <n; j++)
a[j] = a[j + 1];
n--;
//cout << "11111111111" << endl;
//for (auto i : a) cout << i << ' ';
//cout << endl << "1111111111111111" << endl;
}
fout << cnt;
}