공부기록/SWEA

[SWEA] 1209번 [S/W 문제해결 기본] 2일차 - Sum

메델 2023. 10. 27. 00:00
import java.util.Scanner;

public class Solution {
    
    public static void main(String[] args) {
    	
    	Scanner kb = new Scanner(System.in);
    	
    	for (int T = 1; T <= 10; T++) {
    		int[][] arr = new int[100][100];
    		int maxSum = 0; 
    		int n = kb.nextInt(); 
            
    		for (int i = 0; i < 100; i++) {
    			for (int j = 0; j < 100; j++) {
    				arr[i][j] = kb.nextInt();
    			}
    		}
    		
    		for (int i = 0; i < 100; i++) {
    			int rowSum = 0; 
    			int colSum = 0; 
    			for (int j = 0; j < 100; j++) {
    				rowSum += arr[i][j];
    				colSum += arr[j][i];
    			}
    			maxSum = Math.max(maxSum, Math.max(rowSum, colSum));
    		}
    		
    		int crossSum = 0;
    		int crossSum2 = 0;
    		for (int i = 0; i < 100; i++) {
    			crossSum += arr[i][i];
    			crossSum2 += arr[i][99 - i];
    		}
    		
    		maxSum = Math.max(maxSum, Math.max(crossSum, crossSum2));
    		
    		System.out.println("#" + n + " " + maxSum);
    	}
    }
}