For every pair of triplets, Ta = (Ia, Ja, Ka) and Tb = (Ib, Jb, Kb), we define the difference value between Ta and Tb as follows:
D(Ta, Tb) = max {Ia − Ib, Ja − Jb, Ka − Kb} − min {Ia − Ib, Ja − Jb, Ka − Kb}
Now you are given N triplets, could you write a program to calculate the sum of the difference values between every unordered pair of triplets?2 1 2 3 3 2 1 3 1 3 2 4 0 7 2 2 9 0
4 20
时间上限 | 内存上限 |
3000 | 65536 |
·
·
·
·