Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  #define TASK "ABC"
  //freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
  ios_base::sync_with_stdio(0);
 
  int n;
  cin >> n;
 
  vector < pair < int, int > > a(n);
 
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = {x, i};
  }
 
  sort(a.begin(), a.end());
 
  vector < vector < ll > > d(n, vector < ll >(n, 0));
 
  d[0][n - 1] = 0;
  for (int len = n - 1; len > 0; --len)
    for (int i = 0; i + len < n; ++i) {
      int j = i + len;
 
      d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
    }
 
  ll ans = 0;
 
  for (int i = 0; i < n; ++i)
    ans = max(ans, d[i][i] + ll(abs(a[0].second - i)) * a[0].first);
 
  cout << ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:21: error: 'll' was not declared in this scope
   23 |   vector < vector < ll > > d(n, vector < ll >(n, 0));
      |                     ^~
a.cc:23:24: error: template argument 1 is invalid
   23 |   vector < vector < ll > > d(n, vector < ll >(n, 0));
      |                        ^
a.cc:23:24: error: template argument 2 is invalid
a.cc:23:26: error: template argument 1 is invalid
   23 |   vector < vector < ll > > d(n, vector < ll >(n, 0));
      |                          ^
a.cc:23:26: error: template argument 2 is invalid
a.cc:23:45: error: template argument 2 is invalid
   23 |   vector < vector < ll > > d(n, vector < ll >(n, 0));
      |                                             ^
a.cc:23:52: error: expression list treated as compound expression in initializer [-fpermissive]
   23 |   vector < vector < ll > > d(n, vector < ll >(n, 0));
      |                                                    ^
a.cc:25:4: error: invalid types 'int[int]' for array subscript
   25 |   d[0][n - 1] = 0;
      |    ^
a.cc:30:8: error: invalid types 'int[int]' for array subscript
   30 |       d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      |        ^
a.cc:30:26: error: invalid types 'int[int]' for array subscript
   30 |       d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      |                          ^
a.cc:30:39: error: invalid types 'int[int]' for array subscript
   30 |       d[i][j - 1] = max(d[i][j - 1], d[i][j] + ll(abs(a[len].second - j)) * a[len].first);
      |                                       ^
a.cc:31:8: error: invalid types 'int[int]' for array subscript
   31 |       d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
      |        ^
a.cc:31:26: error: invalid types 'int[int]' for array subscript
   31 |       d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
      |                          ^
a.cc:31:39: error: invalid types 'int[int]' for array subscript
   31 |       d[i + 1][j] = max(d[i + 1][j], d[i][j] + ll(abs(a[len].second - i)) * a[len].first);
      |                                       ^
a.cc:34:5: error: expected ';' before 'ans'
   34 |   ll ans = 0;
      |     ^~~~
      |     ;
a.cc:37:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     ans = max(ans, d[i][i] + ll(abs(a[0].second - i)) * a[0].first);
      |     ^~~
      |     abs
a.cc:37:21: error: invalid types 'int[int]' for array subscript
   37 |     ans = max(ans, d[i][i] + ll(abs(a[0].second - i)) * a[0].first);
      |                     ^
a.cc:39:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |   cout << ans;
      |           ^~~
      |           abs