Language: C++

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

int main(){
    
    int n;  cin >> n;
    vector<int> a(n);
    vector<int> m(n, 0);

    for(int i = 1; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        if(i >= 1){
            max_a = *std::max_element(a.begin(), a.at(i-1));
            m.at(i) = max_a;
        }
    }

    m[0] = *std::max_element(a.begin()+1, a.end());

    for(int i = 0; i < n; ++i){
       printf("%d\n", m[i]);
    }
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: error: 'max_a' was not declared in this scope
   16 |             max_a = *std::max_element(a.begin(), a.at(i-1));
      |             ^~~~~
a.cc:16:38: error: no matching function for call to 'max_element(std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   16 |             max_a = *std::max_element(a.begin(), a.at(i-1));
      |                      ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5641:5: note: candidate: 'template<class _FIter> constexpr _FIter std::max_element(_FIter, _FIter)'
 5641 |     max_element(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5641:5: note:   template argument deduction/substitution failed:
a.cc:16:38: note:   deduced conflicting types for parameter '_FIter' ('__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'int')
   16 |             max_a = *std::max_element(a.begin(), a.at(i-1));
      |                      ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5666:5: note: candidate: 'template<class _FIter, class _Compare> constexpr _FIter std::max_element(_FIter, _FIter, _Compare)'
 5666 |     max_element(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5666:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:524:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::max_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  524 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:524:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::max_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  528 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note:   candidate expects 3 arguments, 2 provided