Photoshoot 2

 1 Sec 64 MB |  显示标签
70165
通过提交

题目描述

 

输入格式

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
 上传者
coach
 创建时间
2022-06-29 17:49
 修改时间
2025-04-06 11:53