logo AlgoBeat OnlineJudge
登录 注册

#210342. [ICPC 2024 Xi'an I] Make Them Straight

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

There is a sequence of non-negative integers of length , the -th element of it is .

A sequence is defined as 'good' if and only if there exists a non negative integer that satisfies the following condition:

for all .

To make this sequence 'good', for each , you can do nothing, or pay coin to replace with any non-negative integer.

The question is, what is the minimum cost to make this sequence 'good'.

输入格式

The first line contains an integer , described in the statement.

The second line contains integers .

The third line contains integers .

输出格式

One integer, the answer.

样例

样例输入 1

5
1 4 3 2 5
1 1 1 1 1

样例输出 1

2

样例输入 2

5
1 4 3 2 5
1 9 1 1 1

样例输出 2

3