Upload files to "백준"
This commit is contained in:
38
백준/3029.py
Normal file
38
백준/3029.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
a=input()
|
||||||
|
b=input()
|
||||||
|
|
||||||
|
ahour=int(a[0:2])
|
||||||
|
bhour=int(b[0:2])
|
||||||
|
|
||||||
|
amin=int(a[3:5])
|
||||||
|
bmin=int(b[3:5])
|
||||||
|
|
||||||
|
asec=int(a[6:8])
|
||||||
|
bsec=int(b[6:8])
|
||||||
|
|
||||||
|
if(bsec<asec):
|
||||||
|
bsec+=60
|
||||||
|
amin+=1
|
||||||
|
|
||||||
|
sec = bsec - asec
|
||||||
|
|
||||||
|
if(bmin<amin):
|
||||||
|
bmin+=60
|
||||||
|
ahour+=1
|
||||||
|
|
||||||
|
min = bmin - amin
|
||||||
|
|
||||||
|
hour = bhour - ahour
|
||||||
|
if(hour<0):
|
||||||
|
hour+=24
|
||||||
|
|
||||||
|
if(hour == 0 and min == 0 and sec == 0):
|
||||||
|
hour=24
|
||||||
|
|
||||||
|
|
||||||
|
sec = '{0:02d}'.format(sec)
|
||||||
|
min = '{0:02d}'.format(min)
|
||||||
|
hour = '{0:02d}'.format(hour)
|
||||||
|
|
||||||
|
|
||||||
|
print(hour+ ":" + min + ":" + sec)
|
||||||
26
백준/3663.py
Normal file
26
백준/3663.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import sys
|
||||||
|
sys.setrecursionlimit(10**6)
|
||||||
|
|
||||||
|
def controller(name):
|
||||||
|
def vertical(char):
|
||||||
|
diff = ord(char) - ord('A')
|
||||||
|
return min(diff, 26 - diff)
|
||||||
|
|
||||||
|
total_vertical = sum(vertical(i) for i in name)
|
||||||
|
min_move=1001
|
||||||
|
len_name=len(name)
|
||||||
|
min_horizon=len_name- 1
|
||||||
|
for i in range(len_name):
|
||||||
|
cumu = i + 1
|
||||||
|
while cumu < len_name and name[cumu] == 'A':
|
||||||
|
cumu +=1
|
||||||
|
move = min (2*(len_name-cumu)+i, min_horizon, 2*i+(len_name-cumu))
|
||||||
|
min_move = min(min_move , move)
|
||||||
|
|
||||||
|
return min_move + total_vertical
|
||||||
|
|
||||||
|
N = int(input())
|
||||||
|
for _ in range(N):
|
||||||
|
temp = input().rstrip()
|
||||||
|
print(controller(temp))
|
||||||
|
|
||||||
13
백준/4796.py
Normal file
13
백준/4796.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
case_num = 1
|
||||||
|
|
||||||
|
while True:
|
||||||
|
L, P, V = map(int, input().split())
|
||||||
|
if (L==0 and P==0 and V==0):
|
||||||
|
break
|
||||||
|
tot = 0
|
||||||
|
week = V//P
|
||||||
|
remainder = V % P
|
||||||
|
result = week * L + min(remainder, L)
|
||||||
|
print(f"Case {case_num}: {result}")
|
||||||
|
case_num += 1
|
||||||
|
|
||||||
24
백준/9251.py
Normal file
24
백준/9251.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
|
||||||
|
N = list(map(str, input().strip()))
|
||||||
|
M = list(map(str, input().strip()))
|
||||||
|
|
||||||
|
len_N = len(N)
|
||||||
|
len_M = len(M)
|
||||||
|
|
||||||
|
arr = [[0 for i in range(len_N+1)] for j in range(len_M+1)]
|
||||||
|
|
||||||
|
tot = 0
|
||||||
|
i=0
|
||||||
|
j=0
|
||||||
|
|
||||||
|
for j in range(1, len_M+1):
|
||||||
|
for i in range(1, len_N+1):
|
||||||
|
if(N[i-1] == M[j-1]):
|
||||||
|
arr[j][i] = arr[j-1][i-1] + 1
|
||||||
|
else:
|
||||||
|
arr[j][i] = max(arr[j][i-1], arr[j-1][i])
|
||||||
|
|
||||||
|
print(arr[len_M][len_N])
|
||||||
44
백준/9252.py
Normal file
44
백준/9252.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
sys.setrecursionlimit(10**6)
|
||||||
|
|
||||||
|
A = list(map(str, input().rstrip()))
|
||||||
|
B = list(map(str, input().rstrip()))
|
||||||
|
|
||||||
|
len_A = len(A)
|
||||||
|
len_B = len(B)
|
||||||
|
|
||||||
|
arr = [[0 for i in range(len_B+1)] for j in range(len_A+1)]
|
||||||
|
|
||||||
|
for i in range(1, len_A+1):
|
||||||
|
for j in range(1, len_B+1):
|
||||||
|
if(A[i-1] == B[j-1]):
|
||||||
|
arr[i][j] = arr[i-1][j-1] + 1
|
||||||
|
else:
|
||||||
|
arr[i][j] = max(arr[i-1][j], arr[i][j-1])
|
||||||
|
|
||||||
|
print(arr[len_A][len_B])
|
||||||
|
|
||||||
|
#LCS 구현 방법
|
||||||
|
result = []
|
||||||
|
|
||||||
|
def getText(r, c):
|
||||||
|
if r==0 or c==0:
|
||||||
|
return
|
||||||
|
if A[r-1] == B[c-1]:
|
||||||
|
result.append(A[r-1])
|
||||||
|
getText(r-1, c-1)
|
||||||
|
else:
|
||||||
|
if arr[r-1][c] > arr[r][c-1]:
|
||||||
|
getText(r-1,c)
|
||||||
|
else:
|
||||||
|
getText(r, c-1)
|
||||||
|
|
||||||
|
getText(len_A, len_B)
|
||||||
|
result_reverse = []
|
||||||
|
|
||||||
|
for i in range(len(result)):
|
||||||
|
result_reverse.append(result.pop())
|
||||||
|
|
||||||
|
print(('').join(result_reverse))
|
||||||
Reference in New Issue
Block a user