티스토리 뷰
2001. 파리 퇴치
import java.util.Scanner;
// 210130
// 2001. 파리 퇴치
public class SWEA2001 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int tc = 1; tc <= T; tc++) {
int N = sc.nextInt();
int M = sc.nextInt();
int[][] arr = new int[N][N];
// 입력
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
arr[i][j] = sc.nextInt();
}
}
int max = 0;
for (int i = 0; i <= (N - M); i++) {
for (int j = 0; j <= (N - M); j++) {
int sum = 0;
for (int z=0; z<M; z++) {
for (int w=0; w<M; w++) {
sum += arr[i+z][j+w];
}
}
if (sum > max) max = sum;
}
}
System.out.println("#" + tc + " " + max);
} // for
sc.close();
} // main
}
'코딩테스트 > SW Expert' 카테고리의 다른 글
[SWEA] 2005. 파스칼의 삼각형 (0) | 2021.01.30 |
---|---|
[SWEA] 1989. 초심자의 회문 검사 (0) | 2021.01.30 |
[SWEA] 1284. 수도 요금 경쟁 (0) | 2021.01.30 |
[SWEA] 1954. 달팽이 숫자 (0) | 2021.01.30 |
[SWEA] 2007. 패턴 마디의 길이 (0) | 2021.01.29 |
댓글