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.Q2529; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { static int k; static char[] a = new char[20]; static ArrayList<String> answer = new ArrayList<>(); static boolean[] check = new boolean[10]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); k = sc.nextInt(); for (int i = 0; i < k; i++) { a[i] = sc.next().toCharArray()[0]; } go(0, ""); Collections.sort(answer); System.out.println(answer.get(answer.size() - 1)); System.out.println(answer.get(0)); } private static void go(int index, String num) { if (index == k + 1) { answer.add(num); return; } for (int i = 0; i <= 9; i++) { if (check[i]) continue; //중복 방지 if (index == 0 || good(num.charAt(index - 1), (char) (i + '0'), a[index - 1])) { //부등호 틀린 것 검증 check[i] = true; go(index + 1, num + i); check[i] = false; } } } private static boolean good(char x, char y, char op) { if (op == '<') { if (x > y) return false; } if (op == '>') { if (x < y) return false; } return true; } }
The text was updated successfully, but these errors were encountered:
145bb13
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: