Skip to content

Instantly share code, notes, and snippets.

N, x, y = map(int, input().split())
A = list(map(int, input().split()))
x_set = set()
x_set.add(A[0])
for i in range(2, N, 2):
new_set = set()
for p in x_set:
new_set.add(p + A[i])
new_set.add(p - A[i])
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sumA = [0]
for i in range(N):
sumA.append(sumA[-1] + A[i])
sumB = [0]
for i in range(M):
sumB.append(sumB[-1] + B[i])
ans = 0
N, M, C = map(int, input().split())
A = list(map(int, input().split()))
# 位置ごとの人数をまとめる
cnt = {}
for a in A:
if a not in cnt:
cnt[a] = 0
cnt[a] += 1
def solv(S):
if len(S) <= 2:
return int(S) % 8 == 0 or int(S[::-1]) % 8 == 0
else: # 3桁以上の場合:3桁の8の倍数が作れるかを判定
# 各数字の出現回数
digit_count = [0] * 10
for ch in S:
digit_count[int(ch)] += 1
# 3桁の8の倍数をチェック
from collections import deque
def check(s):
for i in range(N):
if bfs(i, s):
return True
return False
from collections import deque
def bfs(x, k):
que = deque([(x, 0)])
visits = set([x])
while que:
cur, dist = que.popleft()
for nxt in G[cur]:
if nxt in visits:
from itertools import permutations
def need_w(s, h):
return (s + h - 1) // h
def need_h(s, w):
return (s + w - 1) // w
N = int(input())
S = input()
prefixW = [0] * (N + 1) # iまでの白の個数
totalW = 0 # 全体で白が何個あるか
for i in range(N):
prefixW[i + 1] = prefixW[i]
if S[i] == 'W':
prefixW[i + 1] += 1
class BIT:
def __init__(self, n):
self.n = n
self.bit = [0] * (n + 1)
def sum(self, a):
res = 0
i = a - 1
while i >= 0:
res += self.bit[i]
import math
def can(length): # 各丸太をlength以下にできるか?
cuts = 0
for i in range(N):
cuts += math.ceil(A[i] / length) - 1
return cuts <= K