Untitled
raw download clone
TEXT
views 35
,
size 571 b
#include<stdio.h>

int a[1000000];
int eat[1000000];

int main(void){

    int n;
    scanf("%d", &n);

    int b, ans;
    int nextEat = 0;

    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++){

        scanf("%d", &b);
        ans = 0;

        while(!eat[b]){
            ans++;
            eat[ a[nextEat] ] = 1;
            nextEat++;
        }
        if(i == n-1){
            printf("%d\n", ans);
        }
        else{
            printf("%d ", ans);
        }
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.