Arrays
Practice
3.6 (18 votes)
Ad Hoc
Data structures
Heaps
Medium
Trees
普通 難しい
Problem
69% Success 4697 Attempts 50 Points 3s Time Limit 256MB Memory 1024 KB Max Code
Note that time limit has been increased to 3 sec
Mike has 3 arrays \(a,b,c\) of length n and a number k. He wants to find minimal value of
\(\max_{i = 1}^{n} (((a_i + t) \mod{k}) + ((b_i + t) \mod{k}) + ((c_i + t) \mod{k}))\)
over all non-negative integer values of t.
\(\textbf{Input}\)
The first line contains two numbers n and k (\(1 \le n \le 3 \times 10^5,1 \le k \le 10^8\)).
Each of the next n lines contains 3 numbers - \(a_i,b_i,c_i\) (\(0 \le a_i,b_i,c_i < k\)).
\(\textbf{Output}\)
Output the minimal value achievable.
Submissions
Please login to view your submissions
Similar Problems
No similar problems found
Editorial