This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package algorithm; | |
import java.util.*; | |
public class Kakao1 { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
sc.nextLine(); //flush | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package algorithm; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
/** | |
* @author jack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def kakao1_2(user): | |
p = re.compile('[0-9]+') | |
p2 = re.compile(r"[A-Z]+#*\**") | |
f = p.findall(user) | |
f2 = p2.findall(user) | |
result = [0] * 3 | |
for i in range(3): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def baekjoon11399(length, times_to_wait_in_line): | |
times_to_wait_in_line.sort() | |
cal = sum(times_to_wait_in_line) | |
result = cal | |
for i in range(length - 1, 0, -1): | |
cal -= times_to_wait_in_line[i] | |
result += cal | |
return result | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Main { | |
public static int solve(int length, int[] times_to_wait_in_line) { | |
Arrays.sort(times_to_wait_in_line); | |
int cal = Arrays.stream(times_to_wait_in_line) | |
.reduce((a, b) -> a + b) | |
.getAsInt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f(n, a, b): | |
d = [0] * n | |
dd = [0] * n | |
a_start_position = a.index(1) | |
for i in range(n): | |
j = a_start_position + i # | |
d[i] = a[j % n] - a[(j + 1) % n] # 현재 값과 다음 값의 차를 구해주는 점화식 | |
b_start_position = b.index(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.util.Arrays; | |
import java.util.Comparator; | |
import java.util.Scanner; | |
class Meeting { | |
public int start; | |
public int end; | |
public Meeting(int start, int end) { | |
this.start = start; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 앞, 뒤 두번 정렬 하는 이유는 [1, 1], [2, 2], [1, 2], [2, 2]같은 반례가 있음 | |
class Meeting: | |
def __init__(self, begin, end): | |
self.begin = begin | |
self.end = end | |
def algorithm1931(): | |
meeting_list = [] | |
for x in range(int(input())): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibo_bottom_up(n): | |
d = [0] * (n+1) | |
d[0] = 0 | |
d[1] = 1 | |
for i in range(2, n+1): | |
d[i] = d[i-1] + d[i-2] | |
return d[n] | |
def fibo(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
문제의 조건인 n이 1이 될 수 있는, 최솟값을 구할 수 있는 방법은 | |
1. n/3 | |
2. n/2 | |
3. n-1 | |
이 있다. | |
n에서 n/2, n/3, n-1을 거치면 횟수가 +1 | |
한번 거친 후 조건을 n 번을 반복하므로 | |
1 + f(n/2) ,1 + f(n/3),1 + f(n-1) | |
모든 조건을 거치면서 최솟값을 구한다. | |
예 n = 10일 때 n-1을 9번 거쳐간 값과 8번 거쳐간 후 n/2를 한 번 거쳐간 값과 비교 후 값이 작은 것을 사용한다.(이 경우 서로 같으므로 후자 값을 사용하지 않음) |
OlderNewer