Problems
Soldiers Row
include<bits/stdc++.h>
using namespace std;
int main() {
int n, h;
cin >> n;
stack<pair<int, int>>st;
for (int i = 0; i < n; i++) {
cin >> h;
while (!st.empty() and st.top().first <= h) {
st.pop();
}
if (st.empty()) {
cout << "-1 ";
}
else if (h < st.top().first) {
cout << st.top().second << " ";
}
st.push({ h,i });
}
}