Language: C

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 未解決
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = new long[n];
			Data[] datas = new Data[n];
			IntStream.range(0, n).forEach(i -> {
				a[i] = scanner.nextInt();
				datas[i] = new Data(a[i], i);
			});
			Arrays.sort(datas);
			System.out.println(getResult(datas, 0, n - 1, 0, new HashMap<>()));
		}
	}

	private static long getResult(final Data[] datas, final int leftIndex, final int rightIndex, final int index,
			Map<List<Integer>, Long> map) {
		if (index >= datas.length) {
			return 0;
		}
		List<Integer> key = Arrays.asList(leftIndex, rightIndex, index);
		Long result = map.get(key);
		if (null == result) {
			result = Math.max(
					getResult(datas, leftIndex + 1, rightIndex, index + 1, map)
							+ datas[index].value * Math.abs(leftIndex - datas[index].index),
					getResult(datas, leftIndex, rightIndex - 1, index + 1, map)
							+ datas[index].value * Math.abs(rightIndex - datas[index].index));
			map.put(key, result);
		}

		return result;
	}

	private static class Data implements Comparable<Data> {
		final long value;
		final int index;

		Data(long value, int index) {
			super();
			this.value = value;
			this.index = index;
		}

		@Override
		public int compareTo(Data o) {
			if (this.value == o.value) {
				return this.index - o.index;
			}
			if (this.value > o.value) {
				return -1;
			} else {
				return 1;
			}
		}
	}
}


Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.util.Arrays;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.util.Arrays;
      |            ^
main.c:2:1: error: unknown type name 'import'
    2 | import java.util.HashMap;
      | ^~~~~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    2 | import java.util.HashMap;
      |            ^
main.c:3:1: error: unknown type name 'import'
    3 | import java.util.List;
      | ^~~~~~
main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    3 | import java.util.List;
      |            ^
main.c:4:1: error: unknown type name 'import'
    4 | import java.util.Map;
      | ^~~~~~
main.c:4:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    4 | import java.util.Map;
      |            ^
main.c:5:1: error: unknown type name 'import'
    5 | import java.util.Scanner;
      | ^~~~~~
main.c:5:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    5 | import java.util.Scanner;
      |            ^
main.c:6:1: error: unknown type name 'import'
    6 | import java.util.stream.IntStream;
      | ^~~~~~
main.c:6:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    6 | import java.util.stream.IntStream;
      |            ^
main.c:11:1: error: unknown type name 'public'
   11 | public class Main {
      | ^~~~~~
main.c:11:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
   11 | public class Main {
      |              ^~~~
main.c:56:17: error: stray '@' in program
   56 |                 @Override
      |                 ^