From 684912d61f6b99e006b45941e6b4b7e68497d601 Mon Sep 17 00:00:00 2001 From: malaheaven Date: Mon, 27 Dec 2021 20:23:46 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EC=8A=A4=ED=83=9D=20java=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\212\244\355\203\235.java" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "robin/java/src/baekjoon/dataStructure/\354\212\244\355\203\235.java" diff --git "a/robin/java/src/baekjoon/dataStructure/\354\212\244\355\203\235.java" "b/robin/java/src/baekjoon/dataStructure/\354\212\244\355\203\235.java" new file mode 100644 index 00000000..a473e41e --- /dev/null +++ "b/robin/java/src/baekjoon/dataStructure/\354\212\244\355\203\235.java" @@ -0,0 +1,44 @@ +package baekjoon.dataStructure; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Stack; + +public class 스택 { + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + + Stack stack = new Stack(); + + for (int i = 0; i < n; i++) { + String[] input = br.readLine().split(" "); + + String instruction = input[0]; + + if (instruction.equals("push")) { + int num = Integer.parseInt(input[1]); + stack.push(num); + } + + if (instruction.equals("pop")) { + System.out.println(stack.isEmpty() ? -1 : stack.pop()); + } + + if (instruction.equals("size")) { + System.out.println(stack.size()); + } + + if (instruction.equals("empty")) { + System.out.println(stack.isEmpty() ? 1 : 0); + } + + if (instruction.equals("top")) { + System.out.println(stack.isEmpty() ? -1 : stack.peek()); + } + } + } +} From 199f1380ae4649c559e0889bb43f595d623a7b38 Mon Sep 17 00:00:00 2001 From: malaheaven Date: Mon, 27 Dec 2021 20:24:04 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EB=B0=B1=EC=A4=80=20=ED=94=BC?= =?UTF-8?q?=EB=A1=9C=EB=8F=84=20=EC=9E=90=EB=B0=94=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\224\274\353\241\234\353\217\204.java" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "robin/java/src/baekjoon/math/\355\224\274\353\241\234\353\217\204.java" diff --git "a/robin/java/src/baekjoon/math/\355\224\274\353\241\234\353\217\204.java" "b/robin/java/src/baekjoon/math/\355\224\274\353\241\234\353\217\204.java" new file mode 100644 index 00000000..bd95208e --- /dev/null +++ "b/robin/java/src/baekjoon/math/\355\224\274\353\241\234\353\217\204.java" @@ -0,0 +1,49 @@ +package baekjoon.math; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class 피로도 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String[] input = br.readLine().split(" "); + // 피로도 + int a = Integer.parseInt(input[0]); + + // 일 처리 + int b = Integer.parseInt(input[1]); + + // 쉴 때 + int c = Integer.parseInt(input[2]); + + // limit + int m = Integer.parseInt(input[3]); + + int time = 24; + int tired = 0; + int process = 0; + + while (time > 0) { + + + if (tired + a <= m) { + tired += a; + process += b; + + } else { + tired -= c; + + if (tired < 0) { + tired = 0; + } + } + + time--; + } + + System.out.println(process); + } +} From ca8c6ed1e9a1d979ca1e9fcbfca1871ae2885687 Mon Sep 17 00:00:00 2001 From: malaheaven Date: Mon, 27 Dec 2021 20:24:24 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EB=B0=B1=EC=A4=80=20=ED=8A=B8?= =?UTF-8?q?=EB=A6=AC=20=EC=88=9C=ED=9A=8C=20=ED=8C=8C=EC=9D=B4=EC=8D=AC=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\353\246\254\354\210\234\355\232\214.py" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "robin/python/baekjoon/tree/\355\212\270\353\246\254\354\210\234\355\232\214.py" diff --git "a/robin/python/baekjoon/tree/\355\212\270\353\246\254\354\210\234\355\232\214.py" "b/robin/python/baekjoon/tree/\355\212\270\353\246\254\354\210\234\355\232\214.py" new file mode 100644 index 00000000..babbf47f --- /dev/null +++ "b/robin/python/baekjoon/tree/\355\212\270\353\246\254\354\210\234\355\232\214.py" @@ -0,0 +1,52 @@ +""" + +전위 순회(preorder): 루트 -> 왼쪽 자식 -> 오른쪽 자식 +중위 순회(inorder): 왼쪽 자식 -> 루트 -> 오른쪽 자식 +후위 순회(postorder): 왼쪽 자식 -> 오른쪽 자식 -> 루트 +""" + +import sys + +sys.setrecursionlimit(10 ** 6) + + +def preorder(node): + if node == '.': + return + + print(node, end="") # 루트 + preorder(tree[node][0]) # 왼쪽 자식 + preorder(tree[node][1]) # 오른쪽 자식 + + +def inorder(node): + if node == '.': + return + + inorder(tree[node][0]) # 왼쪽 자식 + print(node, end="") # 루트 + inorder(tree[node][1]) # 오른쪽 자식 + + +def postorder(node): + if node == '.': + return + + postorder(tree[node][0]) # 왼쪽 자식 + postorder(tree[node][1]) # 오른쪽 자식 + print(node, end="") # 루트 + + +if __name__ == '__main__': + n = int(input()) + tree = {} + + for _ in range(n): + root, left, right = input().split() + tree[root] = (left, right) + + preorder('A') + print() + inorder('A') + print() + postorder('A') From 8a0a7458915d2b2a050440e8ecbc5f75e9dac8d7 Mon Sep 17 00:00:00 2001 From: malaheaven Date: Mon, 27 Dec 2021 20:24:41 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EB=B0=A9=EA=B8=88=EA=B7=B8=EA=B3=A1=20python=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...51\352\270\210\352\267\270\352\263\241.py" | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 "robin/python/programmers/level2/study21/\353\260\251\352\270\210\352\267\270\352\263\241.py" diff --git "a/robin/python/programmers/level2/study21/\353\260\251\352\270\210\352\267\270\352\263\241.py" "b/robin/python/programmers/level2/study21/\353\260\251\352\270\210\352\267\270\352\263\241.py" new file mode 100644 index 00000000..82db1dab --- /dev/null +++ "b/robin/python/programmers/level2/study21/\353\260\251\352\270\210\352\267\270\352\263\241.py" @@ -0,0 +1,62 @@ +def change_minute(time): + ls = str(time).split(":") + h = int(ls[0]) + m = int(ls[1]) + + minute = h * 60 + minute += m + return minute + + +def change_melody(melody): + melody = melody.replace('C#', 'c') + melody = melody.replace('D#', 'd') + melody = melody.replace('F#', 'f') + melody = melody.replace('G#', 'g') + melody = melody.replace('A#', 'a') + return melody + + +def solution(m, musicinfos): + music = {} + + for input in musicinfos: + ls = input.split(",") + + # 시간 + time_1 = change_minute(ls[0]) + time_2 = change_minute(ls[1]) + time_diff = time_2 - time_1 + + # 노래제목 + title = ls[2] + + # 멜로디 + melody = change_melody(ls[3]) + + # 노래의 길이가 시간보다 더 긴 경우 + melody_time = time_diff - len(melody) + + # 시간만큼 재생된 음악 dictionary에 넣기 + # melody_time 이 음수나 0이 나오면 문자열 길이만큼의 노래만 재생하거나 더 적게 재생 + if melody_time <= 0: + music[melody[:time_diff]] = title + else: + mok, remain = divmod(time_diff, len(melody)) + string_melody = (melody * mok) + melody[:remain] + music[string_melody] = title + + sort_music = dict(sorted(music.items(), reverse=True, key=lambda item: len(item[0]))) + m = change_melody(m) + + for i in sort_music.keys(): + if m in i: + return sort_music.get(i) + + return "(None)" + + +if __name__ == '__main__': + m = "ABC" + musicinfos = ["12:00,12:14,HELLO,C#DEFGAB", "13:00,13:05,WORLD,ABCDEF"] + print(solution(m, musicinfos))