Deep Loves Function Minimization
Practice
4.3 (6 votes)
Sorting
Algorithms
Advanced sorting
Problem
25% Success 1737 Attempts 30 Points 1.5s Time Limit 256MB Memory 1024 KB Max Code

Given a  \(3 * N\) matrix. In one operation you can swap any two-column and you can perform this operation any number of times (including zero). Find the minimum possible value of the given function after performing this operation any number of times (including zero). As this value may become very large, so output the answer modulo \(10^9 +7\). The function is given below:

                                                      

Input Format:

  • The first line contains \(T\) denoting the number of test cases. The description of each test case is as follows.
  • First-line contains an integer \(N\), denoting the number of columns of the matrix.
  • It follows with \(3\) line each contains \(N\) integers.

Output Format:

  • For each test case, print a single line containing one integer — the minimum value \(F\) modulo \(10^9 + 7\).

Constraints:

  • \(1 \leq T \leq 15\)
  • \(2 \leq N \leq 10^5\)
  • \(1 \leq A_{1, i}, A_{2, i}, A_{3, i} \leq 10^4\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Medium
Points:30
Tags:
SortingGreedy Algorithms
Points:30
7 votes
Tags:
AlgorithmsMedium