Photoshoot 2

 1 Sec 64 MB |  获取标签
222683
通过人数尝试人数总提交数

 

题目描述

 

输入格式

The first line of input contains N. The second line contains a1,a2,…,aN. The third line contains b1,b2,…,bN.

输出格式

Print the minimum number of modifications required to produce Farmer John's desired ordering.

样例输入 #1

5
1 2 3 4 5
1 2 3 4 5

样例输出 #1

0

样例输入 #2


5
5 1 3 2 4
4 5 2 1 3

样例输出 #2


2

提示

In first example, the cows are already in the desired order, so no modifications are required.

In second example, two modifications suffice. Here is one way Farmer John can rearrange his cows:

    Choose cow 4 and move it four positions to the left.
    Choose cow 2 and move it two positions to the left.

    5 1 3 2 4
-> 4 5 1 3 2
-> 4 5 2 1 3

来源

USACO 2022 February Contest, Bronze

 

 您尚未登录,无法进行代码提交