Language: Java

#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> A){
    vector<vector<ll>> dp(2001, vector<ll>(2001, 0));
    vector<pair<ll, int>> a(N);
    rep(i,0,N) a[i] = {A[i], i};
    sort(all(a), greater<>());
    ll answer = 0;
    rep(i,0,N+1) rep(j,0,N-i+1) {
        ll lValue = 0, rValue = 0;
        if (i>0) lValue = dp[i-1][j] + a[i+j-1].first * abs((i-1)-a[i+j-1].second);
        if (j>0) rValue = dp[i][j-1] + a[i+j-1].first * abs((N-j)-a[i+j-1].second);
        dp[i][j] = max(lValue, rValue);
        answer = max(dp[i][j], answer);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: illegal character: '#'
#define rep(i,x,y) for(ll i=(x);i<(y);i++)
^
Main.java:4: error: class, interface, enum, or record expected
#define rep(i,x,y) for(ll i=(x);i<(y);i++)
        ^
Main.java:4: error: class, interface, enum, or record expected
#define rep(i,x,y) for(ll i=(x);i<(y);i++)
                                ^
Main.java:4: error: class, interface, enum, or record expected
#define rep(i,x,y) for(ll i=(x);i<(y);i++)
                                      ^
Main.java:5: error: illegal character: '#'
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
^
Main.java:5: error: class, interface, enum, or record expected
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
                                       ^
Main.java:5: error: class, interface, enum, or record expected
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
                                              ^
Main.java:6: error: illegal character: '#'
#define all(x) (x).begin(),(x).end()
^
Main.java:7: error: illegal character: '#'
#ifdef LOCAL
^
Main.java:8: error: illegal character: '#'
#define dump(x)  cerr << #x << " = " << (x) << endl
^
Main.java:8: error: illegal character: '#'
#define dump(x)  cerr << #x << " = " << (x) << endl
                         ^
Main.java:9: error: illegal character: '#'
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
^
Main.java:9: error: illegal character: '#'
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
                         ^
Main.java:10: error: illegal character: '#'
#define dassert(...) assert(__VA_ARGS__)
^
Main.java:11: error: illegal character: '#'
#else
^
Main.java:12: error: illegal character: '#'
#define dump(x)
^
Main.java:13: error: illegal character: '#'
#define debug(x)
^
Main.java:14: error: illegal character: '#'
#define dassert(...)
^
Main.java:15: error: illegal character: '#'
#endif
^
Main.java:19: error: class, interface, enum, or record expected
const ll MOD = 1e9 + 7;
^
Main.java:20: error: class, interface, enum, or record expected
const long double EPS = 1e-8;
^
Main.java:22: error: unnamed classes are a preview feature and are disabled by default.
void solve(long long N, std::vector<long long> A){
^
  (use --enable-preview to enable unnamed classes)
Main.java:22: error: <identifier> expected
void solve(long long N, std::vector<long long> A){
               ^
Main.java:24: error: <identifier> expected
    vector<pair<ll, int>> a(N);
                             ^
Main.java:25: error: class, interface, enum, or record expected
    rep(i,0,N) a[i] = {A[i], i};
    ^
Main.java:26: error: class, interface, enum, or record expected
    sort(all(a), greater<>());
    ^
Main.java:28: error: class, interface, enum, or record expected
    rep(i,0,N+1) rep(j,0,N-i+1) {
    ^
Main.java:30: error: class, interface, enum, or record expected
        if (i>0) lValue = dp[i-1][j] + a[i+j-1].first * abs((i-1)-a[i+j-1].second);
        ^
Main.java:31: error: class, interface, enum, or record expected
        if (j>0) rValue = dp[i][j-1] + a[i+j-1].first * abs((N-j)-a[i+j-1].second);
        ^
Main.java:32: error: class, interface, enum, or record expected
        dp[i][j] = max(lValue, rValue);
        ^
Main.java:33: error: class, interface, enum, or record expected
        answer = max(dp[i][j], answer);
        ^
Main.java:34: error: class, interface, enum, or record expected
    }
    ^
Main.java:36: error: class, interface, enum, or record expected
}
^
Main.java:42: error: class, interface, enum, or record expected
    scanf("%lld",&N);
    ^
Main.java:43: error: class, interface, enum, or record expected
    std::vector<long long> A(N);
    ^
Main.java:44: error: class, interface, enum, or record expected
    for(int i = 0 ; i < N ; i++){
    ^
Main.java:44: error: class, interface, enum, or record expected
    for(int i = 0 ; i < N ; i++){
                    ^
Main.java:44: error: class, interface, enum, or record expected
    for(int i = 0 ; i < N ; i++){
                            ^
Main.java:46: error: class, interface, enum, or record expected
    }
    ^
Main.java:48: error: class, interface, enum, or record expected
    return 0;
    ^
Main.java:49: error: class, interface, enum, or record expected
}
^
43 errors