-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
14-wkdghdwns199 #59
Merged
Merged
14-wkdghdwns199 #59
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,17 @@ | ||
import sys | ||
from heapq import * | ||
input = sys.stdin.readline | ||
T = int(input()) | ||
for _ in range(T): | ||
N = int(input()) | ||
chapters = list(map(int, input().split())) | ||
time_list = [] | ||
min_time=0 | ||
for chapter in chapters : | ||
heappush(time_list, chapter) | ||
while len(time_list) > 1 : | ||
temp =0 | ||
temp += heappop(time_list) + heappop(time_list) | ||
heappush(time_list, temp) | ||
min_time += temp | ||
print(min_time) |
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,49 @@ | ||
import sys | ||
from collections import deque | ||
input = sys.stdin.readline | ||
|
||
dx = [-1,-1,-1,0,0,1,1,1] | ||
dy = [-1,0,1,-1,1,-1,0,1] | ||
|
||
N,M,K = map(int, input().split()) | ||
A = [list(map(int, input().split())) for _ in range(N)] | ||
trees = [[deque() for _ in range(N)] for _ in range(N)] | ||
|
||
for _ in range(M) : | ||
x,y,z = map(int, input().split()) | ||
trees[x-1][y-1].append(z) | ||
|
||
ground = [[5] * N for _ in range(N)] | ||
for _ in range(K) : | ||
|
||
for i in range(N) : | ||
for j in range(N): | ||
trees_length = len(trees[i][j]) | ||
for k in range(trees_length) : | ||
if ground[i][j] >= trees[i][j][k] : | ||
ground[i][j] -= trees[i][j][k] | ||
trees[i][j][k] += 1 | ||
else : | ||
for _ in range(k,trees_length): | ||
ground[i][j] += trees[i][j].pop() // 2 | ||
break | ||
|
||
for i in range(N): | ||
for j in range(N) : | ||
for z in trees[i][j] : | ||
if z % 5 == 0: | ||
for idx in range(8): | ||
move_x = i + dx[idx] | ||
move_y = j + dy[idx] | ||
if 0 <= move_x < N and 0 <= move_y < N : | ||
trees[move_x][move_y].appendleft(1) | ||
ground[i][j] += A[i][j] | ||
|
||
answer = 0 | ||
for i in range(N) : | ||
for j in range(N): | ||
answer += len(trees[i][j]) | ||
print(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,12 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
def power(A,B,C): | ||
if (B == 1) : return A%C | ||
else : | ||
temp = power(A,B//2, C) | ||
if (B%2 == 0) : return temp * temp % C | ||
else : return temp * temp * A % C | ||
|
||
A,B,C = map(int, input().split()) | ||
print(power(A,B,C)) |
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,20 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
N,M = map(int, input().split()) | ||
word_count = {} | ||
for _ in range(N): | ||
word = input().rstrip() | ||
if len(word) >= M : | ||
if word in word_count : | ||
word_count[word][0] += 1 | ||
else : | ||
word_count[word] = [1,len(word)] | ||
|
||
print() | ||
for key in word_count : | ||
print (key) | ||
|
||
sorted_word_list = sorted(word_count, key=lambda key : (-word_count[key][0], -word_count[key][1], key)) | ||
Comment on lines
+8
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ¨μ΄ κΈΈμ΄λ₯Ό λ°λ‘ λ°°μ΄μ μ 리λ₯Ό ν΄λμ ¨κ΅°μ!! else: # λ¨μ΄κ° Mμ΄μμΈ κ²½μ°
if word in word_lst: # λ¨μ΄κ° μλ κ²½μ°
word_lst[word] += 1
else: # λ¨μ΄κ° μλ κ²½μ°
word_lst[word] = 1
word_lst = sorted(word_lst.items(), key = lambda x : (-x[1], -len(x[0]), x[0])) # x[0] = λ¨μ΄, x[1] = λ¨μ΄ λΉλμ μ΄λ κ² λ£μ΄λμ λ€μ λλ²μ§Έ μμλ‘ |
||
print() | ||
for word in sorted_word_list : | ||
print(word) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ μ λ ¬νλ λΆλΆμ λ―Όμλμ΄λ λκ°μλ°μ
λμ λ리μμ get(value, μμλμ¬μ©ν κ°) μΌλ‘ νλ©΄ κ°μ΄ λ€μ΄μμ§ μμλ μΈ μ μλκ±Έλ‘
μ½λλ₯Ό μ’ νΈνκ² μΈ κ±° κ°μμ. νμ€λμ²λΌ κΈΈμ΄κΉμ§ μ μ₯νμλ©΄ μ΄ λ°©λ²μ λͺ» μλλ€λ§..
p.s νμ΄μ¬μμ len ν¨μλ₯Ό μ°λ©΄ μκ°λ³΅μ‘λλ μ΄λ»κ² λ κΉμ? O(1) μ λλ€.
νμ΄μ¬ κ°μ²΄λ κΈΈμ΄κ° λ³ν λλ§λ€ λ΄λΆμ μΉ΄μ΄ν°κ° μ¦κ°νλ―λ‘ μ΄λ―Έ μ μ₯λ valueλ₯Ό κΊΌλ΄μ€λ μμ μ΄λΌ
κΈΈμ΄λ₯Ό λ°ννλ ν¨μκ° λΉ λ₯΄κ² λμκ°λλ€!