Skip to content

Commit 0747c4e

Browse files
committed
[Array] swea-2001
1 parent 68fbb48 commit 0747c4e

File tree

5 files changed

+164
-0
lines changed

5 files changed

+164
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
| 08 | | [SWEA-1210 Ladder1](./src/Array/swea1210) | |
109109
| 09 | | [SWEA-1954 달팽이 숫자](./src/Array/swea1954) | |
110110
| 10 | | [SWEA-2805 농작물 수확하기](./src/Array/swea2805) | |
111+
| 11 | | [SWEA-2001 파리 퇴치](./src/Array/swea2001) | |
111112

112113
### Stack
113114

src/Array/swea2001/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [SW Expert Academy - 2001] 파리 퇴치
2+
3+
![image](https://user-images.githubusercontent.com/22045163/106764102-d295ad80-667a-11eb-8c5e-cc8b62117da7.png)
4+
![image](https://user-images.githubusercontent.com/22045163/106764161-df1a0600-667a-11eb-928f-9efe57d0e70e.png)
5+
![image](https://user-images.githubusercontent.com/22045163/106764270-fb1da780-667a-11eb-85cd-a84058cb76cf.png)

src/Array/swea2001/Solution.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package Array.swea2001;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class Solution {
7+
8+
static int T, N, M, max;
9+
static int[][] map;
10+
11+
public static void main(String[] args) throws Exception {
12+
System.setIn(new FileInputStream("src/Array/swea2001/input.txt"));
13+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
14+
15+
T = Integer.parseInt(br.readLine());
16+
for (int t = 1; t <= T; t++) {
17+
StringTokenizer st = new StringTokenizer(br.readLine());
18+
N = Integer.parseInt(st.nextToken());
19+
M = Integer.parseInt(st.nextToken());
20+
21+
map = new int[N][N];
22+
max = Integer.MIN_VALUE;
23+
24+
for (int i = 0; i < N; i++) {
25+
st = new StringTokenizer(br.readLine());
26+
for (int j = 0; j < N; j++) {
27+
map[i][j] = Integer.parseInt(st.nextToken());
28+
if (i < M-1 || j < M-1) continue;
29+
int sum = 0;
30+
for (int m_i = i; m_i > i-M; m_i--) {
31+
for (int m_j = j; m_j > j-M; m_j--) {
32+
sum += map[m_i][m_j];
33+
}
34+
}
35+
max = Math.max(max, sum);
36+
}
37+
}
38+
39+
System.out.println("#" + t + " " + max);
40+
}
41+
}
42+
}

src/Array/swea2001/input.txt

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
10
2+
5 2
3+
1 3 3 6 7
4+
8 13 9 12 8
5+
4 16 11 12 6
6+
2 4 1 23 2
7+
9 13 4 7 3
8+
6 3
9+
29 21 26 9 5 8
10+
21 19 8 0 21 19
11+
9 24 2 11 4 24
12+
19 29 1 0 21 19
13+
10 29 6 18 4 3
14+
29 11 15 3 3 29
15+
7 5
16+
17 24 11 29 18 21 11
17+
8 5 14 0 19 15 17
18+
18 25 29 1 29 16 16
19+
3 26 27 20 6 2 27
20+
20 13 19 8 13 29 15
21+
8 22 8 23 21 7 6
22+
14 9 9 27 16 23 29
23+
8 6
24+
5 27 4 27 24 9 17 27
25+
22 3 2 17 23 15 16 20
26+
27 27 24 27 9 15 29 26
27+
9 8 4 3 8 15 28 28
28+
27 25 24 7 16 29 20 20
29+
17 6 22 14 2 14 8 27
30+
19 13 6 4 11 10 6 10
31+
14 12 13 4 8 2 25 4
32+
9 5
33+
8 11 16 28 11 15 27 9 15
34+
12 22 10 18 15 5 20 0 27
35+
16 17 4 6 14 25 19 21 11
36+
12 15 26 10 27 18 26 19 4
37+
5 28 22 23 15 9 4 22 4
38+
14 25 17 22 10 8 29 19 0
39+
14 7 5 28 20 16 20 25 9
40+
9 25 12 26 21 12 26 24 23
41+
14 5 27 4 22 1 17 11 16
42+
10 8
43+
2 1 10 12 14 8 14 9 14 6
44+
5 28 6 9 7 16 17 29 18 27
45+
4 3 6 29 15 3 20 13 2 13
46+
28 7 27 22 11 8 19 11 6 2
47+
24 5 22 27 15 11 9 3 25 18
48+
10 11 3 21 13 14 13 13 24 17
49+
19 17 12 18 12 20 8 17 16 22
50+
10 0 14 17 29 1 3 11 28 28
51+
27 25 16 29 19 7 7 19 1 3
52+
6 20 26 23 8 10 21 12 6 0
53+
11 3
54+
15 9 11 16 2 12 10 26 28 0 28
55+
23 28 24 17 10 1 11 23 10 15 16
56+
5 18 6 9 18 29 0 2 9 13 14
57+
14 12 1 6 11 17 15 0 13 13 6
58+
24 3 10 27 27 9 12 25 7 6 1
59+
25 14 14 13 6 13 12 11 23 28 25
60+
4 6 23 4 1 15 11 12 16 11 4
61+
13 19 17 25 3 15 0 11 4 15 20
62+
21 11 3 25 25 12 22 1 17 26 10
63+
8 21 11 6 22 27 7 4 14 21 2
64+
6 15 15 1 27 10 19 28 24 0 17
65+
12 8
66+
1 17 11 27 26 0 16 10 25 12 6 12
67+
0 7 0 4 18 28 8 1 4 3 2 22
68+
3 22 7 25 19 19 26 19 1 0 7 29
69+
0 10 0 16 5 8 2 14 3 1 28 14
70+
3 26 17 16 27 23 24 4 6 26 17 20
71+
18 14 29 7 12 25 16 0 27 2 5 13
72+
25 24 5 0 27 10 15 3 23 4 1 11
73+
28 13 9 19 29 27 22 2 2 6 13 20
74+
4 24 4 3 16 23 3 1 13 11 28 18
75+
13 29 26 21 14 11 6 23 29 25 13 6
76+
7 12 6 21 20 21 4 24 8 4 16 10
77+
14 19 20 18 24 2 3 0 17 23 13 13
78+
13 3
79+
9 14 5 19 19 28 26 17 7 23 1 17 19
80+
1 22 3 22 20 25 21 1 18 18 0 7 0
81+
25 2 22 24 25 18 25 29 19 7 25 27 29
82+
2 14 23 15 4 25 16 29 29 0 22 13 29
83+
10 11 1 18 13 23 7 10 14 29 2 10 4
84+
15 5 12 29 25 25 2 20 12 29 25 12 9
85+
21 19 3 16 6 27 24 25 29 7 5 4 26
86+
29 28 6 18 18 16 26 13 13 23 16 9 4
87+
2 20 13 23 19 12 22 27 26 12 21 29 2
88+
21 0 7 29 25 6 24 27 27 19 3 28 6
89+
7 15 8 13 19 5 29 11 16 12 25 3 17
90+
4 27 3 28 0 24 3 28 13 18 24 6 22
91+
24 6 20 8 2 7 29 13 3 20 29 0 23
92+
14 9
93+
19 27 28 26 4 28 23 14 7 9 27 27 17 21
94+
7 12 29 19 10 5 17 18 19 15 13 13 1 9
95+
2 0 14 7 22 8 8 20 7 10 7 23 19 21
96+
6 5 8 6 24 27 9 17 19 24 25 17 0 19
97+
18 8 18 26 8 24 8 11 15 18 0 23 26 7
98+
17 7 12 15 1 27 24 24 7 24 2 1 19 10
99+
6 18 2 15 21 5 24 11 11 17 24 28 0 6
100+
3 8 12 6 23 6 2 3 7 9 6 18 21 25
101+
14 3 27 11 0 21 27 27 3 29 28 28 6 4
102+
20 3 15 14 13 28 6 4 2 2 14 22 16 7
103+
10 17 1 5 26 22 18 17 8 19 11 3 20 5
104+
11 13 15 14 22 2 25 13 29 5 14 4 27 17
105+
15 10 9 18 0 16 4 25 17 1 6 12 6 20
106+
24 1 24 2 12 7 3 21 10 21 19 29 0 5

src/Array/swea2001/output.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#1 49
2+
#2 159
3+
#3 428
4+
#4 620
5+
#5 479
6+
#6 941
7+
#7 171
8+
#8 968
9+
#9 209
10+
#10 1242

0 commit comments

Comments
 (0)