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
H, W = map(int, input().split()) | |
N = int(input()) | |
a = list(map(int, input().split())) | |
i = 0 | |
for x in range(H): | |
c = [] | |
for y in range(W): | |
c.append(i + 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
n = int(input()) | |
N = input() | |
L = 0 | |
R = 0 | |
num = 0 | |
for c in N: | |
if c == '(': | |
num += 1 | |
else: | |
if num: |
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
import heapq | |
n = int(input()) | |
a = list(map(int, input().split())) | |
former, latter = a[:n], [-1 * i for i in a[2*n:]] | |
sum_former, sum_latter = sum(former), sum(latter) | |
results = [0] * (n+1) | |
results[0] = sum_former |
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
X, Y = map(int, input().split()) | |
print('Brown' if abs(X-Y) <= 1 else 'Alice') |
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
n, m = map(int, input().split()) | |
x = list(map(int, input().split())) | |
y = list(map(int, input().split())) | |
q = 10**9+7 | |
x_sum = 0 | |
y_sum = 0 | |
for i in range(n): | |
x_sum += (2*i - n + 1) * x[i] |
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
n = int(input()) | |
l = [] | |
for i in range(n): | |
l.append(input()) | |
l_sorted = sorted(list(set(l[0]))) | |
ans ='' | |
for ch in l_sorted: |
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
def lcs(s1, s2): | |
dp = [] | |
for s2_k in s2: | |
bgn_idx = 0 | |
for i, cur_idx in enumerate(dp): | |
chr_idx = s1.find(s2_k, bgn_idx) + 1 | |
if not chr_idx: | |
break | |
dp[i] = min(cur_idx, chr_idx) | |
bgn_idx = cur_idx |
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
def lcs(s1, s2): | |
n, m = len(s1), len(s2) | |
dp = [[0] * (m+1) for _ in range(n+1)] | |
for i in range(1, n+1): | |
for j in range(1, m+1): | |
if s1[i-1] == s2[j-1]: | |
dp[i][j] = dp[i-1][j-1] + 1 | |
else: | |
dp[i][j] = max(dp[i-1][j], dp[i][j-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
def levenshtein(s1, s2): | |
n, m = len(s1), len(s2) | |
dp = [[0] * (m+1) for _ in range(n+1)] | |
for i in range(n+1): | |
dp[i][0] = i | |
for j in range(m+1): | |
dp[0][j] = 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
def solve(): | |
INF = 10 ** 12 | |
N, W = map(int, input().split()) | |
items =[] * N | |
for i in range(N): | |
v, w = map(int, input().split()) |