-
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
ca90a5d
commit 68bbd99
Showing
18 changed files
with
292 additions
and
27 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,15 @@ | ||
T = int(input()) | ||
for i in range(T): | ||
H, W, N = map(int, input().split()) | ||
cnt = 0 | ||
for i in range(W): | ||
for j in range(H): | ||
cnt += 1 | ||
if cnt == N: | ||
if i+1 > 9: | ||
print(str(j+1)+str(i+1)) | ||
break | ||
else: | ||
print(str(j+1)+'0'+str(i+1)) | ||
break | ||
|
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,7 @@ | ||
N = int(input()) | ||
N_list = list(map(int, input().split())) | ||
M = int(input()) | ||
M_list = list(map(int, input().split())) | ||
|
||
for ml in M_list: | ||
print(N_list.count(ml), end=' ') |
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 @@ | ||
N = int(input()) | ||
N_list = sorted(list(map(int, input().split()))) | ||
M = int(input()) | ||
M_list = list(map(int, input().split())) | ||
|
||
for ml in M_list: | ||
start=0 | ||
answer = 0 | ||
end=len(N_list)-1 | ||
while start <= end: | ||
mid = (start+end)//2 | ||
if ml < N_list[mid]: | ||
end = mid-1 | ||
elif ml > N_list[mid]: | ||
start = mid+1 | ||
else: | ||
answer += 1 | ||
N_list[mid] = 0 | ||
N_list.sort() | ||
print(answer, end=' ') |
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 @@ | ||
N = int(input()) | ||
N_list = sorted(list(map(int, input().split()))) | ||
M = int(input()) | ||
M_list = list(map(int, input().split())) | ||
|
||
hashmap = {} | ||
for n in N_list: | ||
if n in hashmap: | ||
hashmap[n] += 1 | ||
else: | ||
hashmap[n] = 1 | ||
|
||
print(' '.join(str(hashmap[m]) if m in hashmap else '0' for m in M_list)) |
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,8 @@ | ||
from collections import Counter | ||
N = int(input()) | ||
N_list = input().split() | ||
M = int(input()) | ||
M_list = input().split() | ||
|
||
C = Counter(N_list) | ||
print(' '.join(f'{C[m]}' if m in C else '0' for m in M_list)) |
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,24 @@ | ||
N = int(input()) | ||
N_list = sorted(list(map(int, input().split()))) | ||
M = int(input()) | ||
M_list = list(map(int, input().split())) | ||
|
||
|
||
def binary(n, N, start, end): | ||
while start <= end: | ||
mid = (start+end)//2 | ||
if n==N[mid]: | ||
return N[start:end+1].count(n) | ||
elif n<N[mid]: | ||
return binary(n, N, start, mid-1) | ||
else: | ||
return binary(n, N, mid+1, end) | ||
|
||
n_dict = {} | ||
for n in N_list: | ||
start=0 | ||
end=len(N_list)-1 | ||
if n not in n_dict: | ||
n_dict[n] = binary(n, N_list, start, end) | ||
|
||
print(' '.join(str(n_dict[x]) if x in n_dict else '0' for x in M_list)) |
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,23 @@ | ||
from collections import deque | ||
import sys | ||
input = sys.stdin.readline | ||
q = deque() | ||
|
||
N = int(input()) | ||
for _ in range(N): | ||
val = input().rstrip() | ||
if ' ' in val: | ||
comm, num = val.split() | ||
if comm == 'push': | ||
q.append(num) | ||
elif val == 'pop': | ||
if len(q)==0: print(-1) | ||
else: print(q.pop()) | ||
elif val == 'size': | ||
print(len(q)) | ||
elif val == 'empty': | ||
if len(q)==0: print(1) | ||
else: print(0) | ||
else: | ||
if len(q)==0: print(-1) | ||
else: print(q[-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# x, y를 함께 min 고려해주는 이유는 x, y좌표를 기준으로 w, h까지의 거리와 | ||
# (0, 0)까지의 거리를 고려해야하기 때문입니다. | ||
# 예시 = (1 2 5 4) 이면 답은 1이어야 합니다. | ||
|
||
x, y, w, h = map(int, input().split()) | ||
|
||
print(min(x, y, w-x, h-y)) |
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 |
---|---|---|
@@ -1 +1,19 @@ | ||
N, K = map(int, input().split()) | ||
N, K = map(int, input().split()) | ||
if N-K > 0: | ||
M = N-K | ||
else: | ||
M = 1 | ||
|
||
C_N = 1 | ||
for i in range(1, N+1): | ||
C_N*=i | ||
|
||
C_M = 1 | ||
for j in range(1, M+1): | ||
C_M*=j | ||
|
||
C_K = 1 | ||
for a in range(1, K+1): | ||
C_K*=a | ||
|
||
print(int(C_N/(C_M*C_K))) |
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,7 @@ | ||
N = int(input()) | ||
arr = [list(map(int, input().split())) for _ in range(N)] | ||
|
||
answer = sorted(arr, key=lambda x: (x[0], x[1])) | ||
|
||
for a, b in answer: | ||
print(a, b) |
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, K = map(int, input().split()) | ||
|
||
answer = [] | ||
arr = [i for i in range(1, N+1)] | ||
|
||
cnt = 0 | ||
while len(arr) != len(answer): | ||
index = cnt%N | ||
print('index: ', index) | ||
if arr[index]==0: | ||
index += 1 | ||
continue | ||
cnt += 1 | ||
if (cnt % K) == 0: | ||
answer.append(arr[(cnt%N)-1]) | ||
arr[(cnt%N)-1] = 0 | ||
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,17 @@ | ||
from collections import deque | ||
import sys | ||
input = sys.stdin.readline | ||
N, K = map(int, input().split()) | ||
q = deque([]) | ||
for i in range(1, N+1): | ||
q.append(i) | ||
|
||
print('<', end='') | ||
while q: | ||
for i in range(K-1): | ||
q.append(q[0]) | ||
q.popleft() | ||
print(q.popleft(), end='') | ||
if q: | ||
print(',', end=' ') | ||
print('>', end='') |
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,18 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N, M, x, y, cnt = map(int, input().split()) | ||
|
||
map_list = [list(map(int, input().split())) for _ in range(N)] | ||
move_list = list(map(int, input().split())) | ||
dice = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0} | ||
for m in move_list: | ||
# 주사위 굴리기 & 복사 | ||
if m==1: # 동 | ||
dice[4], dice[1], dice[3], dice[6] = dice[6], dice[4], dice[1], dice[3] | ||
elif m==2: # 서 | ||
dice[4], dice[1], dice[3], dice[6] = dice[1], dice[3], dice[6], dice[4] | ||
elif m==3: # 남 | ||
dice[2], dice[1], dice[5], dice[6] = dice[1], dice[5], dice[6], dice[2] | ||
else: # 북 | ||
dice[2], dice[1], dice[5], dice[6] = |
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,16 @@ | ||
from itertools import combinations | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N, M = map(int, input().split()) | ||
arr = list(map(int, input().split())) | ||
|
||
comb_list = list(combinations(arr, 3)) | ||
|
||
max = -1 | ||
for c in comb_list: | ||
if sum(c) <= M and sum(c) > max: | ||
max = sum(c) | ||
|
||
print(max) | ||
|
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,20 @@ | ||
import math | ||
|
||
def solution(progresses, speeds): | ||
answer = [] | ||
temp = [] | ||
for index, p in enumerate(progresses): | ||
val = math.ceil((100-p)/speeds[index]) | ||
temp.append(val) | ||
|
||
k = 0 | ||
for i in range(len(temp)): | ||
if temp[i] > temp[k]: | ||
answer.append(i-k) | ||
k=i | ||
answer.append(len(temp)-k) | ||
return answer | ||
|
||
if __name__ == '__main__': | ||
result = solution([93, 30, 55], [1, 30, 5]) | ||
print(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def solution(progresses, speeds): | ||
answer = [] | ||
time = 0 | ||
count = 0 | ||
while len(progresses)>0: | ||
if (progresses[0] + time*speeds[0]) >= 100: | ||
progresses.pop(0) | ||
speeds.pop(0) | ||
count += 1 | ||
else: | ||
if count > 0: | ||
answer.append(count) | ||
count = 0 | ||
time += 1 | ||
answer.append(count) | ||
return answer | ||
|
||
if __name__ == '__main__': | ||
result = solution([93, 30, 55], [1, 30, 5]) | ||
print(result) |