[Solution] Digital Logarithm Codeforces Solution
Let's define for a positive integer as the length of the base-10 representation of without leading zeros. I like to call it a digital logarithm. Similar to a digital root, if you are familiar with that.
You are given two arrays and , each containing positive integers. In one operation, you do the following:
- pick some integer from to ;
- assign either to or to .
Two arrays are considered similar to each other if you can rearrange the elements in both of them, so that they are equal (e. g. for all from to ).
What's the smallest number of operations required to make and similar to each other?
The first line contains a single integer () — the number of testcases.
The first line of the testcase contains a single integer () — the number of elements in each of the arrays.
The second line contains integers ().
The third line contains integers ().
The sum of over all testcases doesn't exceed .
For each testcase, print the smallest number of operations required to make and similar to each other.
In the first testcase, you can apply the digital logarithm to twice.
In the second testcase, the arrays are already similar to each other.
In the third testcase, you can first apply the digital logarithm to , then to .
No comments:
Post a Comment