We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main.java.com.poogle.BOJ.Q14500; import java.util.Scanner; public class Main { static int[][][] block = { {{0, 1}, {0, 2}, {0, 3}}, //파랑 가로 길쭉 {{1, 0}, {2, 0}, {3, 0}}, //파랑 세로 길쭉 {{1, 0}, {1, 1}, {1, 2}}, //노랑 정사각형 {{0, 1}, {1, 0}, {2, 0}}, //주황 {{0, 1}, {0, 2}, {1, 2}}, {{1, 0}, {2, 0}, {2, -1}}, {{0, 1}, {0, 2}, {-1, 2}}, {{1, 0}, {2, 0}, {2, 1}}, {{0, 1}, {0, 2}, {1, 0}}, {{0, 1}, {1, 1}, {2, 1}}, {{0, 1}, {1, 0}, {1, 1}}, {{0, 1}, {-1, 1}, {-1, 2}}, //초록 {{1, 0}, {1, 1}, {2, 1}}, {{0, 1}, {1, 1}, {1, 2}}, {{1, 0}, {1, -1}, {2, -1}}, {{0, 1}, {0, 2}, {-1, 1}}, //핑크 {{0, 1}, {0, 2}, {1, 1}}, {{1, 0}, {2, 0}, {1, 1}}, {{1, 0}, {2, 0}, {1, -1}} }; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[][] a = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = sc.nextInt(); } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { for (int k = 0; k < 19; k++) { boolean ok = true; int sum = a[i][j]; for (int l = 0; l < 3; l++) { int x = i + block[k][l][0]; int y = i + block[k][l][1]; if (0 <= x && x < n && 0 <= y && y <= m) { sum += a[x][y]; } else { ok = false; break; } } if (ok && ans < sum) { ans = sum; } } } } System.out.println(ans); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[][] a = new int[n][m]; for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { a[i][j] = sc.nextInt(); } } int ans = 0; for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { if (j+3 < m) { int temp = a[i][j] + a[i][j+1] + a[i][j+2] + a[i][j+3]; if (ans < temp) ans = temp; } if (i+3 < n) { int temp = a[i][j] + a[i+1][j] + a[i+2][j] + a[i+3][j]; if (ans < temp) ans = temp; } if (i+1 < n && j+2 < m) { int temp = a[i][j] + a[i+1][j] + a[i+1][j+1] + a[i+1][j+2]; if (ans < temp) ans = temp; } if (i+2 < n && j+1 < m) { int temp = a[i][j] + a[i][j+1] + a[i+1][j] + a[i+2][j]; if (ans < temp) ans = temp; } if (i+1 < n && j+2 < m) { int temp = a[i][j] + a[i][j+1] + a[i][j+2] + a[i+1][j+2]; if (ans < temp) ans = temp; } if (i+2 < n && j-1 >= 0) { int temp = a[i][j] + a[i+1][j] + a[i+2][j] + a[i+2][j-1]; if (ans < temp) ans = temp; } if (i-1 >= 0 && j+2 < m) { int temp = a[i][j] + a[i][j+1] + a[i][j+2] + a[i-1][j+2]; if (ans < temp) ans = temp; } if (i+2 < n && j+1 < m) { int temp = a[i][j] + a[i+1][j] + a[i+2][j] + a[i+2][j+1]; if (ans < temp) ans = temp; } if (i+1 < n && j+2 < m) { int temp = a[i][j] + a[i][j+1] + a[i][j+2] + a[i+1][j]; if (ans < temp) ans = temp; } if (i+2 < n && j+1 < m) { int temp = a[i][j] + a[i][j+1] + a[i+1][j+1] + a[i+2][j+1]; if (ans < temp) ans = temp; } if (i+1 < n && j+1 < m) { int temp = a[i][j] + a[i][j+1] + a[i+1][j] + a[i+1][j+1]; if (ans < temp) ans = temp; } if (i-1 >= 0 && j+2 < m) { int temp = a[i][j] + a[i][j+1] + a[i-1][j+1] + a[i-1][j+2]; if (ans < temp) ans = temp; } if (i+2 < n && j+1 < m) { int temp = a[i][j] + a[i+1][j] + a[i+1][j+1] + a[i+2][j+1]; if (ans < temp) ans = temp; } if (i+1 < n && j+2 < m) { int temp = a[i][j] + a[i][j+1] + a[i+1][j+1] + a[i+1][j+2]; if (ans < temp) ans = temp; } if (i+2 < n && j-1 >= 0) { int temp = a[i][j] + a[i+1][j] + a[i+1][j-1] + a[i+2][j-1]; if (ans < temp) ans = temp; } if (j+2 < m) { int temp = a[i][j] + a[i][j+1] + a[i][j+2]; if (i-1 >= 0) { int temp2 = temp + a[i-1][j+1]; if (ans < temp2) ans = temp2; } if (i+1 < n) { int temp2 = temp + a[i+1][j+1]; if (ans < temp2) ans = temp2; } } if (i+2 < n) { int temp = a[i][j] + a[i+1][j] + a[i+2][j]; if (j+1 < m) { int temp2 = temp + a[i+1][j+1]; if (ans < temp2) ans = temp2; } if (j-1 >= 0) { int temp2 = temp + a[i+1][j-1]; if (ans < temp2) ans = temp2; } } } } System.out.println(ans); } }
The text was updated successfully, but these errors were encountered:
224669d
boj: 14500 풀이 - 오타 수정
7d8e30f
Issue #50
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: