Language: C++

de <bits/stdc++.h>
typedef long long lint;
using namespace std;

// セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Mnd>
struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while (sz < _sz) sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd& operator[](const int& k) {
        return data[k + sz];
    }
    //木を構築 O(n)
    void build() {
        for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, data[a++]);
            if (b & 1) r = f(r, data[--b]);
        }
        return f(l, r);
    }
};

int main() {
    int n;
    cin >> n;
    segment_tree<lint> a(
        n, [](lint a, lint b) { return max(a, b); }, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.build();
    bool has_kab = false;
    int kab = 0;
    lint money = 1000;
    for (int i = 0; i < n; i++) {
        if (!has_kab) {
            if (a[i] < a.query(i + 1, n)) {
                if (a[i] >= a[i + 1]) {
                    continue;
                }
                kab = money / a[i];
                money -= kab * a[i];
                has_kab = true;
            }
        } else {
            if (i + 1 < n && a[i] <= a[i + 1]) {
                continue;
            } else {
                money += kab * a[i];
                kab = 0;
                has_kab = false;
            }
        }
    }
    cout << money << endl;
}

Compiler output:
a.cc:1:1: error: 'de' does not name a type
    1 | de <bits/stdc++.h>
      | ^~
a.cc:10:5: error: 'vector' does not name a type
   10 |     vector<Mnd> data;
      |     ^~~~~~
a.cc:11:5: error: 'function' does not name a type; did you mean 'union'?
   11 |     function<Mnd(Mnd, Mnd)> f;
      |     ^~~~~~~~
      |     union
a.cc:14:27: error: 'function' has not been declared
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                           ^~~~~~~~
a.cc:14:35: error: expected ',' or '...' before '<' token
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                   ^
a.cc: In constructor 'segment_tree<Mnd>::segment_tree(int, int)':
a.cc:14:65: error: class 'segment_tree<Mnd>' does not have any field named 'f'
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                                                 ^
a.cc:14:67: error: '_f' was not declared in this scope
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                                                   ^~
a.cc:14:74: error: '_e' was not declared in this scope; did you mean 'e'?
   14 |     segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
      |                                                                          ^~
      |                                                                          e
a.cc:17:9: error: 'data' was not declared in this scope
   17 |         data.assign(sz * 2, e);
      |         ^~~~
a.cc: In member function 'Mnd& segment_tree<Mnd>::operator[](const int&)':
a.cc:21:16: error: 'data' was not declared in this scope
   21 |         return data[k + sz];
      |                ^~~~
a.cc: In member function 'void segment_tree<Mnd>::build()':
a.cc:25:42: error: 'data' was not declared in this scope
   25 |         for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
      |                                          ^~~~
a.cc:25:52: error: there are no arguments to 'f' that depend on a template parameter, so a declaration of 'f' must be available [-fpermissive]
   25 |         for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
      |                                                    ^
a.cc:25:52: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In member function 'void segment_tree<Mnd>::update(int, Mnd)':
a.cc:29:9: error: 'data' was not declared in this scope
   29 |         data[k += sz] = x;
      |         ^~~~
a.cc:30:35: error: there are no arguments to 'f' that depend on a template parameter, so a declaration of 'f' must be available [-fpermissive]
   30 |         while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
      |                                   ^
a.cc: In member function 'Mnd segment_tree<Mnd>::query(int, int) const':
a.cc:36:33: error: 'data' was not declared in this scope
   36 |             if (a & 1) l = f(l, data[a++]);
      |                                 ^~~~
a.cc:37:33: error: 'data' was not declared in this scope
   37 |             if (b & 1) r = f(r, data[--b]);
      |                                 ^~~~
a.cc: In function 'int main()':
a.cc:45:5: error: 'cin' was not declared in this scope
   45 |     cin >> n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | de <bits/stdc++.h>
a.cc:46:18: error: 'lint' was not declared in this scope; did you mean 'int'?
   46 |     segment_tree<lint> a(
      |                  ^~~~
      |                  int
a.cc:46:22: error: template argument 1 is invalid
   46 |     segment_tree<lint> a(
      |                      ^
a.cc:47:15: error: 'lint' is not a type
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |               ^~~~
a.cc:47:23: error: 'lint' is not a type
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |                       ^~~~
a.cc: In lambda function:
a.cc:47:40: error: 'max' was not declared in this scope
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |                                        ^~~
a.cc: In function 'int main()':
a.cc:47:55: error: expression list treated as compound expression in initializer [-fpermissive]
   47 |         n, [](lint a, lint b) { return max(a, b); }, 0);
      |                                                       ^
a.cc:49:17: error: invalid types 'int[int]' for array subscript
   49 |         cin >> a[i];
      |                 ^
a.cc:51:7: error: request for member 'build' in 'a', which is of non-class type 'int'
   51 |     a.build();
      |       ^~~~~
a.cc:54:9: error: expected ';' before 'money'
   54 |     lint money = 1000;
      |         ^~~~~~
      |         ;
a.cc:57:18: error: invalid types 'int[int]' for array subscript
   57 |             if (a[i] < a.query(i + 1, n)) {
      |                  ^
a.cc:57:26: error: request for member 'query' in 'a', which is of non-class type 'int'
   57 |             if (a[i] < a.query(i + 1, n)) {
      |                          ^~~~~
a.cc:58:22: error: invalid types 'int[int]' for array subscript
   58 |                 if (a[i] >= a[i + 1]) {
      |                      ^
a.cc:58:30: error: invalid types 'int[int]' for array subscript
   58 |                 if (a[i] >= a[i + 1]) {
      |                              ^
a.cc:61:23: error: 'money' was not declared in this scope
   61 |                 kab = money / a[i];
      |                       ^~~~~
a.cc:61:32: error: invalid types 'int[int]' for array subscript
   61 |                 kab = money / a[i];
      |                                ^
a.cc:62:33: error: invalid types 'int[int]' for array subscript
   62 |                 money -= kab * a[i];
      |                                 ^
a.cc:66:31: error: invalid types 'int[int]' for array subscript
   66 |             if (i + 1 < n && a[i] <= a[i + 1]) {
      |                               ^
a.cc:66:39: error: invalid types 'int[int]' for array subscript
   66 |             if (i + 1 < n && a[i] <= a[i + 1]) {
      |                                       ^
a.cc:69:17: error: 'money' was not declared in this scope
   69 |                 money += kab * a[i];
      |                 ^~~~~
a.cc:69:33: error: invalid types 'int[int]' for array subscript
   69 |                 money += kab * a[i];
      |                                 ^
a.cc:75:5: error: 'cout' was not declared in this scope
   75 |     cout << money << endl;
      |     ^~~~
a.cc:75:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:75:13: error: 'money' was not declared in this scope
   75 |     cout << money << endl;
      |             ^~~~~
a.cc:75:22: error: 'endl' was not declared in this scope
   75 |     cout << money << endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | de <bits/stdc++.h>