---
# System prepended metadata

title: 12132 - too many watermelons
tags: [array]

---

# 12132 - too many watermelons
>author: Utin
###### tags: `array`
---

## Brief
See the code below

## Solution 0

```c=
#include <stdio.h>

int arr[1000005];

int main() {
    int len, start = 0;
    
    scanf("%d", &len);
    for (int i = 0; i < len; ++i) {
        scanf("%d", &arr[i]);
    }
    
    for (int i = 0; i < len; i++) {
        
        int input, flag = 0;
        scanf("%d", &input);
        
        if (start == len) printf("0");
        
        else {
            // 已經吃掉的就不用判斷了
            for (int j = start; j < len; j++) {
                if (arr[j] == input) {
                    printf("%d", j - start + 1);
                    start = j + 1;
                    break;
                }
                else if (j >= len-1) printf("0");
            }
        }
        
        i == len - 1 ? printf("\n") : printf(" ");
    }
}

// Utin
```

## Reference