전체 글
-
boj)10866 - 덱PS/boj 2020. 10. 14. 21:17
import java.io.*; public class boj_10866 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws IOException { int N = Integer.parseInt(br.readLine()); int[] arr = new int[(N*2) + 2]; int head = N; int tail = N; for (int i = 0; i < N; i++) { ..
-
boj)4889 - 안정적인 문자열PS/boj 2020. 10. 14. 15:48
import java.io.*; import java.util.Stack; public class boj_4889 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); String str; int cnt = 0; while ( !(str = br.readLine()).contains("-") ) { cnt++; Stack stack = new Stack(); for (int i = 0..
-
boj)2504 - 괄호의 값PS/boj 2020. 10. 14. 14:42
import java.io.*; import java.util.*; public class boj_2504 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); String str = sc.nextLine(); Stack stack = new Stack(); int roundBracket = 0; int squareBracket = 0; for (int i = 0; i < str.length(); i++) { String s = str.substri..
-
boj)4949 - 균형잡힌 세상PS/boj 2020. 10. 13. 17:49
import java.io.*; import java.util.*; public class boj_4949 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws IOException { while (true) { String input = br.readLine(); if (input.equals(".")) { break; } sb.append(solve(input) ? "yes" : "no").append("\n"); } System.out.pri..
-
boj)6198 - 옥상 정원 꾸미기PS/boj 2020. 10. 13. 12:57
import java.io.*; import java.util.*; public class boj_6198 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static Stack stack = new Stack(); public static void main(String[] args) throws IOException { long ans = 0; int N = Integer.parseInt(br.readLine()); for (int i = 0; i < N; i++) { int height = Integer.parseInt(br.readLine()); while (!stack.isEmpty()) { if ..
-
boj)2164 - 카드2PS/boj 2020. 10. 12. 16:28
import java.io.*; import java.util.*; public class boj_2164 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { Queue q = new LinkedList(); int N = Integer.parseInt(br.readLine()); for (int i = 1; i
-
boj)2493 - 탑PS/boj 2020. 10. 12. 13:02
import java.io.*; import java.util.*; public class boj_2493 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static Stack waiting = new Stack(); static Stack pending = new Stack(); static StringTokenizer st; public static void main(String[] args) throws IOException { int n = Integ..
-
boj)10773 - 제로PS/boj 2020. 10. 12. 11:08
import java.io.*; import java.util.Stack; public class boj_10773 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static Stack s = new Stack(); public static void main(String[] args) throws IOException { long ans = 0; int k = Integer.parseInt(br.readLine()); for (int i = 0; i < k; i++) { int val = Integer.parseInt(br.readLine()); if (val == 0) { ans -= s.pop(); ..