Submission #172473


Source Code Expand

Copy
import java.util.Scanner;

public class Main {

    public static int R;
    public static int C;
    public static int D;
    public static int[][] array;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        R = sc.nextInt();
        C = sc.nextInt();
        D = sc.nextInt();
        array = new int[R][];
        for (int i = 0; i < R; i++) {
            array[i] = new int[C];
            for (int j = 0; j < C; j++) {
                array[i][j] = sc.nextInt();
            }
        }
        if (R + C - 2 > D) {
            System.out.println(test(1, 1, D));
        } else {
            System.out.println(test2());
        }
    }

    public static int test(int x, int y, int count) {
        int max = 0;
        if (count == 0) {
            if (x < 1 || y < 1 || x > R || y > C) {
                return 0;
            }
            return array[x - 1][y - 1];
        } else {
            int[] diffX = {-1, 0, 1, 0};
            int[] diffY = {0, -1, 0, 1};
            for (int i = 0; i < diffX.length; i++) {
                int result = test(x + diffX[i], y + diffY[i], count - 1);
                if (max < result) {
                    max = result;
                }
            }
            return max;
        }
    }
    
    public static int test2() {
        int max = 0;
        for (int i = 0; i < R; i++) {
            for (int j = 0; j < C; j++) {
                if ((i + j + D) % 2 == 0) {
                    if (max < array[i][j]) {
                        max = array[i][j];
                    }
                }
            }
        }
        return max;
    }
}

Submission Info

Submission Time
Task B - 謎の人物X
User tksy
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 1716 Byte
Status TLE
Exec Time 2105 ms
Memory 41544 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 60 0 / 40
Status
AC × 3
AC × 5
TLE × 13
AC × 3
TLE × 27
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 531 ms 22920 KB
sample_02.txt AC 491 ms 22996 KB
sample_03.txt AC 478 ms 23008 KB
subtask1_01.txt AC 498 ms 22988 KB
subtask1_02.txt TLE 2041 ms 31604 KB
subtask1_03.txt TLE 2041 ms 31664 KB
subtask1_04.txt TLE 2045 ms 33264 KB
subtask1_05.txt TLE 2042 ms 31612 KB
subtask1_06.txt TLE 2042 ms 33072 KB
subtask1_07.txt AC 681 ms 31000 KB
subtask1_08.txt TLE 2046 ms 36940 KB
subtask1_09.txt TLE 2045 ms 36840 KB
subtask1_10.txt TLE 2047 ms 36908 KB
subtask1_11.txt TLE 2043 ms 36512 KB
subtask1_12.txt TLE 2047 ms 36876 KB
subtask1_13.txt TLE 2043 ms 36848 KB
subtask1_14.txt TLE 2043 ms 36688 KB
subtask1_15.txt TLE 2043 ms 36724 KB
subtask2_01.txt TLE 2042 ms 32160 KB
subtask2_02.txt TLE 2058 ms 32168 KB
subtask2_03.txt TLE 2053 ms 38340 KB
subtask2_04.txt TLE 2043 ms 33528 KB
subtask2_05.txt TLE 2051 ms 37204 KB
subtask2_06.txt AC 1021 ms 37140 KB
subtask2_07.txt TLE 2055 ms 40000 KB
subtask2_08.txt TLE 2087 ms 39908 KB
subtask2_09.txt TLE 2081 ms 40672 KB
subtask2_10.txt TLE 2077 ms 41292 KB
subtask2_11.txt TLE 2069 ms 41336 KB
subtask2_12.txt TLE 2105 ms 40620 KB
subtask2_13.txt TLE 2082 ms 40208 KB
subtask2_14.txt TLE 2082 ms 41544 KB
subtask2_15.txt TLE 2083 ms 41360 KB