-
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
c3ca68c
commit 2256202
Showing
5 changed files
with
96 additions
and
16 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,22 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N = int(input()) | ||
N_arr = sorted(list(map(int, input().split()))) | ||
M = int(input()) | ||
M_arr = list(map(int, input().split())) | ||
|
||
for marr in M_arr: | ||
answer = 0 | ||
start = 0 | ||
end = len(N_arr) - 1 | ||
while start <= end: | ||
mid = (start + end) // 2 | ||
if N_arr[mid] > marr: | ||
end = mid-1 | ||
elif N_arr[mid] < marr: | ||
start = mid+1 | ||
else: | ||
answer = 1 | ||
break | ||
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,20 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
n = int(input()) | ||
arr = [list(map(int, input().split())) for _ in range(n)] | ||
temp = 0 | ||
|
||
|
||
def dfs(a, t, i, j): | ||
visited[i][j] = True | ||
a[i][j] | ||
pass | ||
|
||
|
||
while True: | ||
visited = [[False] * n for _ in range(n)] | ||
for i_i, i in enumerate(arr): | ||
for i_j, j in enumerate(arr): | ||
if not visited[i_i][i_j] and arr[i_i][i_j] > temp: | ||
dfs(arr, temp, i_i, i_j) |
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 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N = int(input()) | ||
arr = list(map(int, input().split())) | ||
|
||
min = sys.maxsize | ||
answer = 0 | ||
for a in arr: | ||
for b in arr: | ||
if a+b < min: | ||
min = abs(a+b) | ||
answer = a, b | ||
for i in sorted(answer): | ||
print(i, 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,24 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N = int(input()) | ||
arr = sorted(list(map(int, input().split()))) | ||
|
||
start = 0 | ||
end = len(arr)-1 | ||
|
||
min = sys.maxsize | ||
while start < end: | ||
calc = arr[start] + arr[end] | ||
if abs(calc) < min: | ||
min = abs(calc) | ||
answer = arr[start], arr[end] | ||
if calc == 0: | ||
break | ||
if calc < 0: | ||
start += 1 | ||
else: | ||
end -= 1 | ||
|
||
for i in sorted(answer): | ||
print(i, 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 |
---|---|---|
@@ -1,24 +1,23 @@ | ||
import sys | ||
from itertools import permutations | ||
input = sys.stdin.readline | ||
|
||
N = int(input()) | ||
words = [list(input().rstrip()) for _ in range(N)] | ||
all_words_duplicate = set(sum(words, [])) | ||
num = [i for i in range(10)] | ||
|
||
# # 순열 | ||
# perm = set(permutations(num, len(all_words_duplicate))) | ||
word_dict = {} | ||
|
||
for p in set(permutations(num, len(all_words_duplicate))): | ||
# print(list(zip(all_words_duplicate, p))) | ||
# print(p) | ||
for key, value in list(zip(all_words_duplicate, p)): | ||
print(key, value) | ||
for word in words: | ||
pass | ||
# 숫자 이어 붙힘 | ||
for word in words: | ||
k = len(word)-1 | ||
for w in word: | ||
if w in word_dict: | ||
word_dict[w] += 10 ** k | ||
else: | ||
word_dict[w] = 10 ** k | ||
k -= 1 | ||
|
||
# 계산해 | ||
|
||
# 최댓값 | ||
sorted_word = sorted(word_dict.values(), reverse=True) | ||
answer, num = 0, 9 | ||
for sw in sorted_word: | ||
answer += sw * num | ||
num -= 1 | ||
print(answer) |