I’m trying to solve this question. But I don’t know where I’m going wrong as the code seems to be right and I tried some cases, it does work upon that too. Maybe I’m missing some more understanding but help me with this.
Input
1
5
1 1 1 1 1
Expected Output
5 5 5 5 5
Your Output
1 2 2 2 1
I did realize this mistake and added this line.
while(!b.empty() && now>=b.top().ff){
if(now==b.top().ff){
ans[i]++; ans[b.top().ss]++;
}
b.pop();
}
could you help me in improvising this problem
I am really sorry. Expected Output is:
4 4 4 4 4