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, K = map(int, input().split()) | |
a = list(map(int, input().split())) | |
a = sorted(a) | |
ans = N | |
t = 0 | |
for i in range(N-1, -1, -1) : | |
if t+a[i] < K : | |
t += a[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
W, H = map(int, input().split()) | |
C = int(1e9)+7 | |
fact = [1] | |
for x in range(1, H+W-1): | |
fact.append( (x * fact[x-1]) % C ) | |
factinv = [1] * (H+W-1) | |
factinv[H+W-2] = pow(fact[H+W-2], C-2, 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
from math import lgamma, exp, log | |
lfact = lambda n: lgamma(n + 1) | |
lcomb = lambda n, r: lfact(n) - lfact(n - r) - lfact(r) | |
n, d = map(int, input().split()) | |
x, y = map(abs, map(int, input().split())) | |
if x % d != 0 or y % d != 0: | |
print('0') | |
exit(0) | |
x //= d |
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 = [int(input()) for _ in range(3)] | |
if N in l: | |
print('NO') | |
else: | |
flag = False | |
for i in range(100): | |
if N <= 3: | |
flag = True |
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
l = [int(input()) for _ in range(N)] #N: 入力される数値の個数 |
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
l = [] | |
for _ in range(N): #N: 入力される数値の個数 | |
l.append(int(input()) |
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(): | |
A, B, C, D, E, F = map(int, input().split()) | |
memo = {} | |
for a in range(31): | |
for b in range(31): | |
for c in range(101): | |
for d in range(101): | |
w = (100*A)*a + (100*B)*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
import math | |
from collections import Counter | |
N, A, B = map(int, input().split()) | |
v = list(map(int, input().split())) | |
v.sort(reverse = True) | |
cnt_v = Counter(v) | |
ave = [] |
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 math | |
def order(A, B): | |
ord_A = int(math.log10(A) + 1) | |
ord_B = int(math.log10(B) + 1) | |
return max(ord_A, ord_B) | |
def solve(): | |
N = int(input()) | |
d = 10**12 |
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 |