Language: C++

#include<iostream>
#include<stack>
using namespace std;

int main(){
  stack<int>s;
  stack<int>t;
  int n,b[100]; cin>>n;
  int i=n;
  for(int i=n;i>=1;i--)
    cin>>b[i];
  while(i>=1){
  if(b[i]>i){
    cout<<-1<<endl;
  }
  else if(b[i]==1&&b[i+1]!=1){
   for(int x=i;x<=n;x++){
     s.push(b[x]);
     if(b[x]>b[x+1]){
       s.pop();
       while(b[x+1]==b[x-1]){
         t.push(s.top);
         s.pop();
         b[x+1]--;
       }
       int a=x+1;
       for(a;a<=n;a++){
         if(b[a]<b[x]){
           s.push(b[a]);
         }
       }
       s.push(t);
     }
    }   
  }
  }
    i--;
   }
  cout<<s<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: no matching function for call to 'std::stack<int>::push(<unresolved overloaded function type>)'
   22 |          t.push(s.top);
      |          ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/stack:63,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  258 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:258:30: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::stack<int>::value_type&' {aka 'const int&'}
  258 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  263 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:263:25: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::stack<int>::value_type&&' {aka 'int&&'}
  263 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:32:14: error: no matching function for call to 'std::stack<int>::push(std::stack<int>&)'
   32 |        s.push(t);
      |        ~~~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  258 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:258:30: note:   no known conversion for argument 1 from 'std::stack<int>' to 'const std::stack<int>::value_type&' {aka 'const int&'}
  258 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]'
  263 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:263:25: note:   no known conversion for argument 1 from 'std::stack<int>' to 'std::stack<int>::value_type&&' {aka 'int&&'}
  263 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc: At global scope:
a.cc:39:3: error: 'cout' does not name a type
   39 |   cout<<s<<endl;
      |   ^~~~
a.cc:40:3: error: expected unqualified-id before 'return'
   40 |   return 0;
      |   ^~~~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^