Language: C++

#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;


 
int main() {
    int64_t n;
    cin >> n;
    int64_t b[n-1];
    for (int i = 0; i < n-1; ++i)
        cin >> b[i];

    int64_t sum = 0;
    int64_t curmax = b[n-2];
    for (int i = n-2; i >= 0; --i) {
	if (curmax > b[i]) {
	    curmax = b[i];
	}
	// cerr << curmax << endl;
	sum += curmax;
    }
    sum += curmax;
    cout << sum << endl;
}


Compiler output:
a.cc:15:14: error: 'int64_t' was not declared in this scope
   15 | typedef pair<int64_t, int64_t> pii;
      |              ^~~~~~~
a.cc:4:1: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    3 | #include <vector>
  +++ |+#include <cstdint>
    4 | using namespace std;
a.cc:15:23: error: 'int64_t' was not declared in this scope
   15 | typedef pair<int64_t, int64_t> pii;
      |                       ^~~~~~~
a.cc:15:23: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:15:30: error: template argument 1 is invalid
   15 | typedef pair<int64_t, int64_t> pii;
      |                              ^
a.cc:15:30: error: template argument 2 is invalid
a.cc:20:16: error: 'int64_t' was not declared in this scope
   20 | typedef vector<int64_t> vii;
      |                ^~~~~~~
a.cc:20:16: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:20:23: error: template argument 1 is invalid
   20 | typedef vector<int64_t> vii;
      |                       ^
a.cc:20:23: error: template argument 2 is invalid
a.cc:23:7: error: 'int64_t' does not name a type
   23 | const int64_t infi = 1147483600;
      |       ^~~~~~~
a.cc:23:7: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'int main()':
a.cc:32:5: error: 'int64_t' was not declared in this scope
   32 |     int64_t n;
      |     ^~~~~~~
a.cc:32:5: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:33:5: error: 'cin' was not declared in this scope
   33 |     cin >> n;
      |     ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <vector>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:33:12: error: 'n' was not declared in this scope
   33 |     cin >> n;
      |            ^
a.cc:34:12: error: expected ';' before 'b'
   34 |     int64_t b[n-1];
      |            ^~
      |            ;
a.cc:36:16: error: 'b' was not declared in this scope
   36 |         cin >> b[i];
      |                ^
a.cc:38:12: error: expected ';' before 'sum'
   38 |     int64_t sum = 0;
      |            ^~~~
      |            ;
a.cc:39:12: error: expected ';' before 'curmax'
   39 |     int64_t curmax = b[n-2];
      |            ^~~~~~~
      |            ;
a.cc:41:13: error: 'curmax' was not declared in this scope
   41 |         if (curmax > b[i]) {
      |             ^~~~~~
a.cc:41:22: error: 'b' was not declared in this scope
   41 |         if (curmax > b[i]) {
      |                      ^
a.cc:45:9: error: 'sum' was not declared in this scope
   45 |         sum += curmax;
      |         ^~~
a.cc:45:16: error: 'curmax' was not declared in this scope
   45 |         sum += curmax;
      |                ^~~~~~
a.cc:47:5: error: 'sum' was not declared in this scope
   47 |     sum += curmax;
      |     ^~~
a.cc:47:12: error: 'curmax' was not declared in this scope
   47 |     sum += curmax;
      |            ^~~~~~
a.cc:48:5: error: 'cout' was not declared in this scope
   48 |     cout << sum << endl;
      |     ^~~~
a.cc:48:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:48:20: error: 'endl' was not declared in this scope
   48 |     cout << sum << endl;
      |                    ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include <vector>
  +++ |+#include <ostream>
    4 | using namespace std;