Try to work hard !

import java.util.Scanner;
import java.util.Stack;
 
class Solution {
 
    public static void main(String args[]) throws Exception {
 
        Scanner sc = new Scanner(System.in);
        int[] pair = new int[256]; // 아스키코드
         
        pair['('] = ')';
        pair['['] = ']';
        pair['{'] = '}';
        pair['<'] = '>';
         
        for (int T = 1; T <= 10; T++) {
 
            Stack<Character> stack = new Stack();
            boolean possible = true;
 
            // [input] Test 번호
            int inputLen = Integer.parseInt(sc.nextLine());
             
            // [input] 데이터 입력 & 풀이
            String line = sc.nextLine();
            for (int i = 0; i < inputLen; i++) {
                 
                char input = line.charAt(i);
                // 괄호시작
                if(input == '(' ||input == '[' ||input == '{' ||input == '<')
                {
                    stack.push(input);
                }
                 
                // 괄호끝
                if(input == ')' ||input == ']' ||input == '}' ||input == '>')
                {
                    if(stack.empty()) {
                        possible = false;
                        break;
                    }
                     
                    if(pair[stack.pop().charValue()] != input) {
                        possible = false;
                        break;
                    }
                }
            }
 
            System.out.println(String.format("#%d %d", T, possible?1:0));
        }
 
    }
 
}


Comment +0

import java.util.Scanner;
 
class Solution {
 
    public static void main(String args[]) throws Exception {
 
        Scanner sc = new Scanner(System.in);
 
        for (int T = 1; T <= 10; T++) {
 
            int[][] map = new int[100][100];
            int patternLen = 0;
 
            // [input] Test 번호
            int TestNo = Integer.parseInt(sc.nextLine());
 
            // [input] 데이터 입력
            for (int i = 0; i < 100; i++) {
                String line = sc.nextLine();
                for (int j = 0; j < 100; j++) {
                    map[i][j] = line.charAt(j) - 'A';
                }
            }
 
            // 단순 반복 (length 100부터 1까지)
            for(int l=100; l>0; l--) {
                boolean isFound = findPattern(map, l);
                if(isFound) {
                    patternLen = l;
                    break;
                }
            }
 
            System.out.println(String.format("#%d %d", T, patternLen));
        }
 
    }
 
    public static boolean findPattern(int[][] map, int length) {
        // 1.열 기준 검색
        for (int k = 0; k < 100; k++) {
            for (int m = 0; m < 100 - length + 1; m++) {
                // 명확하게 시작점과 끝점을 재정의하자!
                int startIndex = m;
                int endIndex = m + length - 1;
 
                // 회문 체크 (행기준)
                for (int l = 0; l < length / 2; l++) {
                    if (map[k][startIndex + l] != map[k][endIndex - l]) {
                        break;
                    }
                    if (l == length / 2 - 1) {
                        return true;
                    }
                } // 회문 체크 END
 
                // 회문체크 (열기준)
                for (int l = 0; l < length / 2; l++) {
                    if (map[startIndex + l][k] != map[endIndex - l][k]) {
                        break;
                    }
                    if (l == length / 2 - 1) {
                        return true;
                    }
                } // 회문 체크 END
 
            }
        }
        return false;
    }
 
}


Comment +0

import java.util.Scanner;
 
 
class Solution {
    static int Answer;
 
    static int[][] map = new int[16][16]; // 행, 열
    static int[][] visited = new int[16][16]; // 행, 열
    static boolean findPath ;
     
    public static void main(String args[]) throws Exception {
         
         
        Scanner sc = new Scanner(System.in);
         
        for(int T=1; T <=10; T++) {
             
            // Test 번호
            sc.nextLine(); 
            int startX = -1, startY = -1;
             
            //map에 데이터 입력
            for(int i=0; i<16; i++) { // 행(y)
                String rowInput = sc.nextLine();
                for(int j=0; j<16; j++) { // 열(x)
                    // j => x , i => y
                    map[i][j] = rowInput.charAt(j) - '0';
                    visited[i][j] = 0;
                    if(map[i][j] == 2) {
                        startY = i;
                        startX = j;
                    }
                }
            }
             
            findPath = false;
            findView(startY, startX);
             
            System.out.println(String.format("#%d %d", T, findPath ? 1:0));
        }
         
    }
     
    public static void findView(int y, int x) {
        // 1, -1이 겹치지 않게 방향설정 (왼쪽, 아랫쪽, 오른쪽, 위쪽)
        int[] rotX = {-1,0,1,0};
        int[] rotY = {0,1,0,-1};
         
        // 도킹
        visited[y][x] = 1;
        int newX, newY;
        for(int i=0; i<4; i++) {
            // 왼쪽, 아랫쪽, 오른쪽, 위쪽을 우선순위로 탐색
            newX = x + rotX[i];
            newY = y + rotY[i];
            if(isWay(newY, newX)) { // 길이 있는 경우면 전진
                 
                // 도중에 출구를 발견한 경우
                if(map[newY][newX]==3) {
                    findPath = true;
                    break;
                }
                 
                findView(newY, newX); // 무한 재귀호출
            }
        }
        // 도킹 해제
        visited[y][x] = 0;
    }
     
    public static boolean isWay(int y, int x) {
        if(x<0 || x>15 || y<0 || y>15) { // 배열 범위를 넘어서는 경우
            return false;
        }else if(visited[y][x]==1){ // 지나온 곳은 통과할 수 없다.
            return false;
        }else if(map[y][x]==1) { // 벽은 통과할 수 없다.
            return false;
        }else if(findPath) {
            // 이미 길을 찾은 경우 break point 재귀함수를 모두 종류하기 위하여
            return false;
        }
        return true;
    }
     
}


Comment +0

import java.util.Scanner;
 
 
class Solution {
    static int Answer;
 
    public static void main(String args[]) throws Exception {
         
         
        Scanner sc = new Scanner(System.in);
         
        for(int T=1; T <=10; T++) {
             
            // dump 횟수
            int dumpCount = sc.nextInt();
            sc.nextLine();
             
            // 숫자 리스트
            String[] strNumList = sc.nextLine().trim().split(" ");
            int[] countArr = new int[101]; // 0 ~ 100
             
            // 각각의 숫자들을 카운팅
            int min=101, max=0;
            for(String strNum : strNumList) {
                int height = Integer.parseInt(strNum);
                countArr[height]++;
            }
             
             
            for(int j=0; j<=dumpCount; j++) {
                // 최대값 스캔
                for(int k=100; k>=0; k--) {
                    if(countArr[k] != 0) {
                        max = k;
                        break;
                    }
                }
                 
                // 최소값 스캔
                for(int k=0; k<=100; k++) {
                    if(countArr[k] != 0) {
                        min = k;
                        break;
                    }
                }
                 
                if(j!=dumpCount) {
                    // 블록옴기기 ( 0 ~ dumpCount-1 까지)
                    countArr[max]--;
                    countArr[max-1]++;
                    countArr[min]--;
                    countArr[min+1]++;
                }
            }
             
             
            // 높이차 출력
            System.out.println(String.format("#%d %d", T, max-min) );
             
        }
         
    }
}


Comment +0

import java.util.Scanner;
 
 
class Solution {
    static int Answer;
 
    public static void main(String args[]) throws Exception {
         
         
        Scanner sc = new Scanner(System.in);
         
        for(int T=1; T <=10; T++) {
            int size = sc.nextInt();
            int