← 返回 akunacapital 的题目列表Maximize Distinct Elements After Swaps
类型:online_judge
Given two integer arrays a and b, both of length n, and an integer k.
In one operation, choose an index i and an index j, then swap a[i] with b[j]. You may perform at most k swaps.
Return the maximum possible number of distinct integers in array a after the swaps.
Input Format
First line: two integers n k
Second line: n integers representing a
Third line: n integers representing b
Output Format
Print one integer: the maximum number of distinct values in a.
Example
Input:
5 2
2 3 3 2 2
1 3 2 4 1
Output:
4
One valid result is:
a = [2, 3, 1, 2, 4]
which contains four distinct values.
Example
Input
5 2
2 3 3 2 2
1 3 2 4 1
Output
4