#include <stdio.h>

int main() {
    int x[500],y[500],s[500];
    int a,b,c,d;
    scanf("%d",&a);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&x[i]);
    }
    for(int i=0;i<a;i++)
    {
        s[i]=x[i];
        if(i==0)
        {
            y[i]=0;
        }
        else if(s[i]-x[i-1]>0)
        {
            y[i]=0;
            for(int j=0;j<i;j++)
            {
                s[j]=x[i];
            }
        }
        else if(s[i]-x[i-1]<0)
        {
            y[i]=i;
        }
        else
        {
            y[i]=0;
        }
    }
    for(int i=0;i<a;i++)
    {
        printf("%d ",y[i]);
    }
    }

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: