▶문제설명
[SWEA] 1209. Sum
https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV13_BWKACUCFAYh&categoryId=AV13_BWKACUCFAYh&categoryType=CODE
▶Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import java.util.*; class Solution{ public static int[][] arr = new int[100][100]; public static void main(String[] args){ Scanner sc = new Scanner(System.in); for( int t = 1 ; t<=10 ; t++) { int answer = 0; int T = sc.nextInt(); int SumR, SumC, SumX1, SumX2; int[] SumArrR = new int[100]; int[] SumArrC = new int[100]; SumR = SumC = SumX1 = SumX2 = 0; for(int i = 0 ; i<100 ; i++){ for(int j = 0 ; j<100 ; j++){ arr[i][j] = sc.nextInt(); SumArrR[i] += arr[i][j]; SumArrC[j] += arr[i][j]; if(i==j) SumX1 += arr[i][j]; if( j==99-i) SumX2 += arr[i][j]; } } int max = 0; int g = 0; max = Math.max(SumX1, SumX2); for(int i = 0 ; i<100 ; i++){ g = Math.max(SumArrR[i], SumArrC[i]); if(max < g) max = g; } answer = max; System.out.printf("#%d %d\n", T, answer); } } } | cs |
'■ 알고리즘 문제 풀이 > SWEA' 카테고리의 다른 글
[SWEA-D4] 1211. Ladder2 (0) | 2019.02.20 |
---|---|
[SWEA-D4] 1210. Ladder1 (0) | 2019.02.20 |
[SWEA-D3] 1206. View (0) | 2019.02.20 |
[SWEA-D3] 1208. Flatten (0) | 2019.02.20 |
[SWEA-D2] 1204. 최빈수 구하기 (0) | 2019.02.20 |