Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  
  2. import java.util.*;
  3.  
  4.  
  5. public class Main {
  6.     static int[][] map;
  7.     static int[][] dp;
  8.     static int N;
  9.     static int M;
  10.     public static void main(String[] args) {
  11.         Scanner sc = new Scanner(System.in);
  12.        
  13.         int T;
  14.         T = sc.nextInt();
  15.         for(int i=0;i<T;i++){
  16.             N = sc.nextInt();
  17.             M = sc.nextInt();
  18.             map = new int[N+1][N+1];
  19.             dp = new int[N][N];
  20.             for(int j=0;j<N;j++){
  21.                 for(int k=0;k<N;k++){
  22.                     map[j][k] = sc.nextInt();
  23.                 }
  24.                
  25.             }
  26.            
  27.             int max =0;
  28.             for(int n=0;n<N-1;n++){
  29.                 for(int m=0;m<N-1;m++){
  30.                     dp[n][m] = map[n][m]+map[n][m+1]+map[n+1][m]+map[n+1][m+1];
  31.                     if(dp[n][m]>max)
  32.                         max = dp[n][m];
  33.                 }
  34.             }
  35.             System.out.println(max);
  36.         }
  37.        
  38.        
  39.     }
  40.  
  41.    
  42.    
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement