-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2001.java
56 lines (46 loc) · 1.51 KB
/
p2001.java
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
47
48
49
50
51
52
53
54
55
56
package self.samsungExpert;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
// platform | SWEA
// number | 2001
// title | 파리 퇴치
// level | D2
// how |
// etc |
// result |
public class p2001 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
int[][] arr;
for(int t=1; t<=T; t++) {
st = new StringTokenizer(br.readLine(), " ");
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
arr = new int[N+1][N+1];
for(int j=0; j<N; j++) {
st = new StringTokenizer(br.readLine(), " ");
for(int k=0; k<N; k++) {
arr[j][k] = Integer.parseInt(st.nextToken());
}
}
int max = 0;
for(int i=0; i<N-M+1; i++) {
for(int j=0; j<N-M+1; j++) {
int sum = 0;
for(int k=0; k<M; k++) {
for(int p=0; p<M; p++) {
sum += arr[i+k][j+p];
}
if(max < sum)
max = sum;
}
}
}
System.out.println("#" + t + " " + max);
}
}
}