-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecdf8f8
commit acc1b59
Showing
9 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
n, m = map(int, input().split()) | ||
d = [[-1]*(m+1) for _ in range(n+1)] | ||
|
||
# n, m에서 왼쪽, 왼쪽위, 위 방향으로 이동하면서 1, 1에 도착했을때의 개수를 더한다. | ||
def dp(n, m): | ||
if n==0 or m==0: | ||
return 0 | ||
if n==1 and m==1: | ||
return 1 | ||
if d[n][m]!=-1: | ||
return d[n][m] | ||
result = (dp(n,m-1)+dp(n-1,m)+dp(n-1,m-1))%1000000007 | ||
d[n][m] = result | ||
return result | ||
|
||
print(dp(n, m)%1000000007) |
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import heapq | ||
|
||
def solution(scoville, K): | ||
heap = [] | ||
for num in scoville: | ||
heapq.heappush(heap, num) | ||
|
||
answer = 0 | ||
while heap[0] < K: | ||
answer += 1 | ||
try: | ||
heapq.heappush(heap, heapq.heappop(heap)+(heapq.heappop(heap)*2)) | ||
except IndexError: | ||
return -1 | ||
return answer | ||
|
||
if __name__ == '__main__': | ||
real_answer = solution([1, 2, 3, 9, 10, 12], 7) | ||
print(real_answer) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def solution(A): | ||
answer = [] | ||
SA = set(A) | ||
for i in SA: | ||
cnt = 0 | ||
for j in A: | ||
cnt += abs(i-j) | ||
answer.append(cnt) | ||
return min(answer) | ||
|
||
if __name__ == '__main__': | ||
real_answer = solution([3, 2, 1, 1, 2, 3, 1]) | ||
print(real_answer) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def solution(A, B): | ||
temp = [] | ||
if len(A)<len(B): temp = B; B = A; A = temp | ||
A.sort() | ||
B.sort() | ||
i = 0 | ||
for a in A: | ||
if i < len(B) - 1 and B[i] < a: | ||
i += 1 | ||
if a == B[i]: | ||
return a | ||
return -1 | ||
|
||
if __name__ == '__main__': | ||
real_answer = solution([1,3,2,5],[4,4,4,4,4,5]) | ||
print(real_answer) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def solution(A): | ||
answer = [] | ||
sumval=0 | ||
for i in A: | ||
if i<0: | ||
answer.append(sumval) | ||
sumval=0 | ||
else: | ||
sumval+=i | ||
answer.append(sumval) | ||
return max(answer) | ||
|
||
if __name__ == '__main__': | ||
real_answer = solution([-8,3,0,5,-3,12]) | ||
print(real_answer) |
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
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