# help for problem 'DOMSOL' https://www.codechef.com/problems/DOMSOL

can someone tell me why my code is getting ‘wrong answer’ for the problem ‘DOMSOL’

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int column = sc.nextInt();
int[][] matrix = new int[2][column];
for(int i = 0; i < 2; i++) {
for(int j = 0; j < column; j++) {
matrix[i][j] = sc.nextInt();
}
}
// for(int i = 0; i < 2; i++) {
//     for(int j = 0; j < column; j++) {
//         System.out.println(matrix[i][j]);
//     }
// }
int type = 1; // vertical
long score = Math.abs(matrix[0][0] - matrix[1][0]);
// System.out.println(score);
for (int i = 1; i < column; i++) {
if (type == 1) {
if ((Math.abs(matrix[0][i-1] - matrix[1][i-1]) + Math.abs(matrix[0][i] - matrix[1][i])) >= (Math.abs(matrix[0][i] - matrix[0][i-1]) + Math.abs(matrix[1][i] - matrix[1][i-1]))) {
score += Math.abs(matrix[0][i] - matrix[1][i]);
} else {
type = 2;
score += - Math.abs(matrix[0][i-1] - matrix[1][i-1])
+ Math.abs(matrix[0][i] - matrix[0][i-1])
+ Math.abs(matrix[1][i] - matrix[1][i-1]);
}
} else {
int a = Math.abs(matrix[0][i] - matrix[1][i]) + Math.abs(matrix[0][i-1] - matrix[0][i-2]) + Math.abs(matrix[1][i-1] - matrix[1][i-2]);
int b = Math.abs(matrix[0][i-2] - matrix[1][i-2]) + Math.abs(matrix[0][i] - matrix[0][i-1]) + Math.abs(matrix[1][i] - matrix[1][i-1]);
if (a >= b) {
type = 1;
score += Math.abs(matrix[0][i] - matrix[1][i]);
} else {
score -= Math.abs(matrix[0][i-1] - matrix[0][i-2]) + Math.abs(matrix[1][i-1] - matrix[1][i-2]);
score += b;
}
}
}
System.out.println(score);
}
}``````
//