본문 바로가기

전체 글262

[알고리즘 문제] Seat import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int width = sc.nextInt(); // 공연장의 가로길이 int height = sc.nextInt(); // 공연장의 세로길이 int order = sc.nextInt(); // 대기순서 int direction = 1; int x = 0, y = -1; boolean down = true, up = false, right = false, left = false; // 시계방향으로 탐색할 수 있도록 도와주는 변수 int[][] ary = new int[height][wid.. 2019. 4. 4.
[알고리즘 문제] Tetris import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int width = sc.nextInt(); // 테트리스 가로 int height = sc.nextInt(); // 테트리스 세로 int[][] ary = new int[height][width]; // 현재 테트리스를 저장하는 배열 boolean depthChecek; // 막대기를 넣었을 때 맵을 벗어나는지 검사 int depthCheckFailList = 0; // 막대기를 넣었을때 맵상을 벗어나는 경우의 수 List mapList = new LinkedList(); // ㅣ모양 블럭을 .. 2019. 4. 3.
[알고리즘 문제] 대푯값 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; int sum = 0; int modeFrequency = 0; // 최빈값의 최대 빈도수 int modeCount = 0; // 최대 최빈값을 가지는 숫자의 개수 int mode = 0; // 최빈값 int[] ary = new int[101]; for (int i = 0; i < 10; i++) { n = sc.nextInt(); sum += n; // 입력받은 숫자를 계속 더해줌 ary[n / 10]++; // 입력받은 정수의 빈도수를 ary배열에 체크, 10의 배수이.. 2019. 4. 2.
[알고리즘] Class President import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[][] ary = new int[n][6]; List check = new LinkedList(); // 같은 반이였던 학생수를 확인/ 검사 int n = sc.nextInt(); // 학생의 수 int num; // 입력받을 값 int value; // 현재n번째 학생의 n학년 int max = 0; // 얼마나 많은 학생과 같은반이였는지 최대값 int maxIndex = 0; // 가장 많은 학생들과 같은반을 한 학생 int maxCount = 0; // 최대값이 몇번 중복되는지 확인 .. 2019. 4. 2.
[알고리즘 문제] Mine import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int height = sc.nextInt(); int width = sc.nextInt(); int y = sc.nextInt() - 1; int x = sc.nextInt() - 1; int[][] ary = new int[height][width]; int mineCount = 0; for (int a = 0; a < height; a++) { for (int b = 0; b < width; b++) { ary[a][b] = sc.nextInt(); } } if (ary[y][x].. 2019. 3. 31.
[알고리즘 문제] ColorPaper import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int y, x, width, height; int[][] ary = new int[102][102]; // 전체 배열 int[] extent = new int[n + 1]; // 각 색종이의 넓이를 계산하는 배열 for (int i = 1; i 2019. 3. 30.
[알고리즘 문제] Offset import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, num; int[][] ary = new int[5][5]; // 입력받은 행렬을 저장 int[][] check = new int[5][5]; // 상하좌우에 있는 값보다 제일 작은값을 체크하는 배열 for (int i = 0; i < 5; i++) { // 모든 행렬 입력받기 for (int k = 0; k < 5; k++) { ary[i][k] = sc.nextInt(); } } // 꼭지점 부분을 먼저 확인 if (ary[0][0] < ary[1][0] && ary[0.. 2019. 3. 27.
[알고리즘 문제] Box Painting import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // 색상의 갯수 int count = 0; // 칠해진 숫자 count int[] colors = new int[1000]; // 색상의 빈도수를 체크 int num; // 입력받은 숫자 if (n < 6) { // 모든 면을 칠해야 함. System.out.println("NO"); return; } for (int i = 0; i < n; i++) { num = sc.nextInt(); if (colors[num] < 2) { // 1 1 1.. 2019. 3. 27.
[알고리즘 문제] Matrix Upside Down 2 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int count = 0; int[][] ary = new int[10][10]; for (int a = 0; a < 10; a++) { // 입력받은 배열로 초기화 해준다. for (int b = 0; b < 10; b++) { ary[a][b] = sc.nextInt(); } } for (int i = 0; i < n; i++) { for (int x = 0; x < 10; x++) { // x부분을 뒤집는 부분 if (ary[i][x] == .. 2019. 3. 26.