#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> heights) {
vector<int> answer;
vector<int> reverse;
for(int i = heights.size()-1; i >= 0; i--){
if(i == 0){
reverse.push_back(0);
continue;
}
int curr = heights[i];
for(int j = i-1; j >= 0; j--){
int prev = heights[j];
if(prev <= curr){
if(j==0) reverse.push_back(0);
continue;
}
reverse.push_back(j+1);
break;
}
}
//반환할 때 벡터 다시 거꾸로
for(int i = reverse.size()-1; i >= 0; i--){
int temp = reverse[i];
answer.push_back(temp);
}
return answer;
}