#P13950. [EC Final 2019] Value
[EC Final 2019] Value
题目描述
believes that one cannot make an omelet without breaking eggs.
For a subset of , we calculate the score of as follows:
- Initialize the score as .
- For any , add to the score.
- For any pair of integers satisfying , , and , if there exists positive integer such that , subtract from the score.
Find the maximum possible score over the choice of .
输入格式
The first line contains a single integer .
The second line contains integers .
The third line contains integers .
输出格式
Print a single integer --- the maximum possible score.
4
1 1 1 2
1 1 1 1
4
4
1 1 1 1
1 1 1 2
3