diff --git "a/weekly/week01/BOJ_10828_\354\212\244\355\203\235/sukangpunch.java" "b/weekly/week01/BOJ_10828_\354\212\244\355\203\235/sukangpunch.java" new file mode 100644 index 0000000..5124740 --- /dev/null +++ "b/weekly/week01/BOJ_10828_\354\212\244\355\203\235/sukangpunch.java" @@ -0,0 +1,71 @@ +package stduy.week01; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +// 스택 +public class BOJ_10828 { + static class MyStack{ + int [] st; + int top; + + public MyStack(int size){ + this.st = new int[size]; + this.top = -1; + } + + public void push(int x){ + st[++top] = x; + } + + public int pop(){ + if(top == -1){ + return -1; + } + + return st[top--]; + } + + public int size(){ + return top + 1; + } + + public int empty(){ + if(top == -1){ + return 1; + } + + return 0; + } + + public int top(){ + if(top == -1){ + return -1; + } + + return st[top]; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + + int N = Integer.parseInt(br.readLine()); + + MyStack stack = new MyStack(N); + for (int i = 0; i < N; i++) { + String []s = br.readLine().split(" "); + + switch(s[0]){ + case "push": stack.push(Integer.parseInt(s[1])); break; + case "pop": sb.append(stack.pop()).append("\n"); break; + case "size": sb.append(stack.size()).append("\n"); break; + case "empty": sb.append(stack.empty()).append("\n"); break; + case "top": sb.append(stack.top()).append("\n"); break; + } + } + System.out.println(sb); + } +} diff --git "a/weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/sukangpunch.java" "b/weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/sukangpunch.java" new file mode 100644 index 0000000..7a32e13 --- /dev/null +++ "b/weekly/week01/BOJ_1920_\354\210\230 \354\260\276\352\270\260/sukangpunch.java" @@ -0,0 +1,53 @@ +package stduy.week01; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; + +public class BOJ_1920 { + + static int [] A; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + + int N = Integer.parseInt(br.readLine()); + String [] s = br.readLine().split(" "); + A = new int[N]; + for(int i=0;i end){ + return 0; + } + + int mid = (start + end) / 2; + + if(A[mid] == target){ + return 1; + }else if(A[mid] > target){ + return findNumByBinarySearch(start, mid - 1, target); + }else{ + return findNumByBinarySearch(mid + 1, end, target); + } + } + +}