12132 - too many watermelons
raw download clone
C
views 24
,
size 545 b
#include <stdio.h>

int main(void)
{
    int n, i, j, x;
    long a[200000];

    scanf("%d", &n);
    for (i=1; i<=n; i++)
    {
        scanf("%d", &j);
        a[j] = i;
    }
    x = 0;
    for (i=1; i<=n; i++)
    {
        scanf("%d", &j);
        if (a[j] > x)
        {
            printf("%d", a[j] - x);
            x = a[j];
        }
        else
        {
            printf("0");
        }
        if (i != n)
        {
            printf(" ");
        }
    }
    printf("\n");

    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.