Language: C++

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

__int64 a[2010];
__int64 maxDis[2010];
__int64 cnt[2010];
int main()
{
    __int64 n, x;
    scanf("%I64d%I64d", &n, &x);
    for(__int64 i = 1; i <= n; ++i)
        scanf("%I64d", &a[i]);
    for(__int64 i = 1; i <= n; ++i)
    {
        __int64 min_j = i;
        __int64 min_v = a[i];
        __int64 min_dis = 0;
        for(__int64 j = 1; j <= n; ++j)
        {
            if(j <= i)
            {
                if(a[j] + (i - j) * x < min_v)
                {
                    min_v = a[j] + (i - j) * x;
                    min_j = j;
                    min_dis = i - j;
                }
                else if(a[j] + (i - j) * x == min_v && i - j < min_dis)
                {
                    min_dis = i - j;
                    min_j = j;
                }

            }
            else
            {
                if(a[j] + (n - j + i) * x < min_v)
                {
                    min_v = a[j] + (n - j + i) * x;
                    min_j = j;
                    min_dis = n - j + i;
                }
                else if(a[j] + (n - j + i) * x == min_v && n - j + i < min_dis)
                {
                    min_dis = n - j + i;
                    min_j = j;
                }
            }
        }
        ++cnt[min_j];
        maxDis[min_j] = max(maxDis[min_j], min_dis);
    }
    __int64 ans = 0;
    for(__int64 i = 1; i <= n; ++i)
        ans += a[i] * cnt[i] + x * maxDis[i];
    printf("%I64d\n", ans);
    return 0;
}


Compiler output:
a.cc:4:1: error: '__int64' does not name a type; did you mean '__int64_t'?
    4 | __int64 a[2010];
      | ^~~~~~~
      | __int64_t
a.cc:5:1: error: '__int64' does not name a type; did you mean '__int64_t'?
    5 | __int64 maxDis[2010];
      | ^~~~~~~
      | __int64_t
a.cc:6:1: error: '__int64' does not name a type; did you mean '__int64_t'?
    6 | __int64 cnt[2010];
      | ^~~~~~~
      | __int64_t
a.cc: In function 'int main()':
a.cc:9:5: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
    9 |     __int64 n, x;
      |     ^~~~~~~
      |     __ynf64
a.cc:10:26: error: 'n' was not declared in this scope; did you mean 'yn'?
   10 |     scanf("%I64d%I64d", &n, &x);
      |                          ^
      |                          yn
a.cc:10:30: error: 'x' was not declared in this scope
   10 |     scanf("%I64d%I64d", &n, &x);
      |                              ^
a.cc:11:16: error: expected ';' before 'i'
   11 |     for(__int64 i = 1; i <= n; ++i)
      |                ^~
      |                ;
a.cc:11:24: error: 'i' was not declared in this scope
   11 |     for(__int64 i = 1; i <= n; ++i)
      |                        ^
a.cc:12:25: error: 'a' was not declared in this scope
   12 |         scanf("%I64d", &a[i]);
      |                         ^
a.cc:13:16: error: expected ';' before 'i'
   13 |     for(__int64 i = 1; i <= n; ++i)
      |                ^~
      |                ;
a.cc:13:24: error: 'i' was not declared in this scope
   13 |     for(__int64 i = 1; i <= n; ++i)
      |                        ^
a.cc:15:16: error: expected ';' before 'min_j'
   15 |         __int64 min_j = i;
      |                ^~~~~~
      |                ;
a.cc:16:16: error: expected ';' before 'min_v'
   16 |         __int64 min_v = a[i];
      |                ^~~~~~
      |                ;
a.cc:17:16: error: expected ';' before 'min_dis'
   17 |         __int64 min_dis = 0;
      |                ^~~~~~~~
      |                ;
a.cc:18:20: error: expected ';' before 'j'
   18 |         for(__int64 j = 1; j <= n; ++j)
      |                    ^~
      |                    ;
a.cc:18:28: error: 'j' was not declared in this scope; did you mean 'jn'?
   18 |         for(__int64 j = 1; j <= n; ++j)
      |                            ^
      |                            jn
a.cc:22:20: error: 'a' was not declared in this scope
   22 |                 if(a[j] + (i - j) * x < min_v)
      |                    ^
a.cc:22:41: error: 'min_v' was not declared in this scope
   22 |                 if(a[j] + (i - j) * x < min_v)
      |                                         ^~~~~
a.cc:25:21: error: 'min_j' was not declared in this scope
   25 |                     min_j = j;
      |                     ^~~~~
a.cc:26:21: error: 'min_dis' was not declared in this scope
   26 |                     min_dis = i - j;
      |                     ^~~~~~~
a.cc:28:64: error: 'min_dis' was not declared in this scope
   28 |                 else if(a[j] + (i - j) * x == min_v && i - j < min_dis)
      |                                                                ^~~~~~~
a.cc:31:21: error: 'min_j' was not declared in this scope
   31 |                     min_j = j;
      |                     ^~~~~
a.cc:37:20: error: 'a' was not declared in this scope
   37 |                 if(a[j] + (n - j + i) * x < min_v)
      |                    ^
a.cc:37:45: error: 'min_v' was not declared in this scope
   37 |                 if(a[j] + (n - j + i) * x < min_v)
      |                                             ^~~~~
a.cc:40:21: error: 'min_j' was not declared in this scope
   40 |                     min_j = j;
      |                     ^~~~~
a.cc:41:21: error: 'min_dis' was not declared in this scope
   41 |                     min_dis = n - j + i;
      |                     ^~~~~~~
a.cc:43:72: error: 'min_dis' was not declared in this scope
   43 |                 else if(a[j] + (n - j + i) * x == min_v && n - j + i < min_dis)
      |                                                                        ^~~~~~~
a.cc:46:21: error: 'min_j' was not declared in this scope
   46 |                     min_j = j;
      |                     ^~~~~
a.cc:50:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   50 |         ++cnt[min_j];
      |           ^~~
      |           int
a.cc:50:15: error: 'min_j' was not declared in this scope
   50 |         ++cnt[min_j];
      |               ^~~~~
a.cc:51:9: error: 'maxDis' was not declared in this scope
   51 |         maxDis[min_j] = max(maxDis[min_j], min_dis);
      |         ^~~~~~
a.cc:51:44: error: 'min_dis' was not declared in this scope
   51 |         maxDis[min_j] = max(maxDis[min_j], min_dis);
      |                                            ^~~~~~~
a.cc:53:12: error: expected ';' before 'ans'
   53 |     __int64 ans = 0;
      |            ^~~~
      |            ;
a.cc:54:16: error: expected ';' before 'i'
   54 |     for(__int64 i = 1; i <= n; ++i)
      |                ^~
      |                ;
a.cc:54:24: error: 'i' was not declared in this scope
   54 |     for(__int64 i = 1; i <= n; ++i)
      |                        ^
a.cc:55:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   55 |         ans += a[i] * cnt[i] + x * maxDis[i];
      |         ^~~
      |         abs
a.cc:55:16: error: 'a' was not declared in this scope
   55 |         ans += a[i] * cnt[i] + x * maxDis[i];
      |                ^
a.cc:55:23: error: 'cnt' was not declared in this scope; did you mean 'int'?
   55 |         ans += a[i] * cnt[i] + x * maxDis[i];
      |                       ^~~
      |                       int
a.cc:55:36: error: 'maxDis' was not declared in this scope
   55 |         ans += a[i] * cnt[i] + x * maxDis[i];
      |                                    ^~~~~~
a.cc:56:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   56 |     printf("%I64d\n", ans);
      |                       ^~~
      |                       abs