Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 98a775b

Browse files
committed
이예진: [BOJ] 1749 점수따먹기_241204
1 parent e65c4c3 commit 98a775b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎BOJ/1000-5000번/YJ_1749.java‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class YJ_1749 {
5+
public static void main(String[] args) throws IOException {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
StringTokenizer st = new StringTokenizer(br.readLine());
8+
int N = Integer.parseInt(st.nextToken())+1;
9+
int M = Integer.parseInt(st.nextToken())+1;
10+
int [][] game = new int[N][M];
11+
12+
for(int i = 1; i < N; i++) {
13+
st = new StringTokenizer(br.readLine());
14+
for(int j = 1; j < M; j++) {
15+
game[i][j] = Integer.parseInt(st.nextToken());
16+
}
17+
}
18+
//누적합
19+
for(int i = 1; i < N; i++) {
20+
for(int j = 1; j < M; j++) {
21+
game[i][j] = game[i-1][j] + game[i][j-1] - game[i-1][j-1] + game[i][j];
22+
}
23+
}
24+
25+
int max = game[1][1];
26+
for(int i = 1; i < N; i++) {
27+
for(int j = 1; j < M; j++) {
28+
for(int r = 0; r < i; r++) {
29+
for(int k = 0; k < j; k++) {
30+
max = Math.max(max, game[i][j] - game[r][j] - game[i][k] + game[r][k]);
31+
}
32+
}
33+
}
34+
}
35+
System.out.println(max);
36+
}
37+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /