AtCoder Beginner Contest 134 - Golden Apple

There are N apple trees in a row. People say that one of them will bear golden apples.
We want to deploy some number of inspectors so that each of these trees will be inspected.
Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).
Find the minimum number of inspectors that we need to deploy to achieve the objective.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 20
 - 1 \leq D \leq 20

-----Input-----
Input is given from Standard Input in the following format:
N D

-----Output-----
Print the minimum number of inspectors that we need to deploy to achieve the objective.

-----Sample Input-----
6 2

-----Sample Output-----
2

We can achieve the objective by, for example, placing an inspector under Tree 3 and Tree 4.

Source: atcoder | Difficulty: EASY


Solutions:
(a, b) = map(int, input().split())
print(a // (2 * b + 1) + (a % (2 * b + 1) != 0))


(n, d) = map(int, input().split())
print(0 - -n // (2 * d + 1))


(n, d) = map(int, input().split())
c = 0
p = d * 2 + 1
tmp = 0
while n > tmp:
	tmp = tmp + p
	c += 1
print(c)


(N, D) = map(int, input().split())
C = D * 2 + 1
ans = (N + C - 1) // C
print(ans)


(n, d) = map(int, input().split())
d = d * 2 + 1
if n % d == 0:
	print(n // d)
else:
	print(n // d + 1)


(inp1, inp2) = map(int, input().split())
print((inp1 + 2 * inp2) // (2 * inp2 + 1))


def answer(n: int, d: int) -> int:
	from math import ceil
	return ceil(n / (d * 2 + 1))

def main():
	(n, d) = map(int, input().split())
	print(answer(n, d))

def __starting_point():
	main()
__starting_point()


(N, D) = map(int, input().split())
w = D * 2 + 1
ans = 0 - -N // w
print(ans)


(N, D) = map(int, input().split())
print(-(-N // (2 * D + 1)))


(n, d) = map(int, input().split())
x = 2 * d + 1
print((n + x - 1) // x)


def mapt(fn, *args):
	return list(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(n, d) = Input()
	d = 2 * d + 1
	return (n + d - 1) // d
print(main())


(n, d) = map(int, input().split())
a = 2 * d + 1
ans = -(-n // a)
print(ans)


(N, D) = list(map(int, input().split()))
gard = D * 2 + 1
print((int(N / gard), int(N / gard) + 1)[N % gard != 0])


(a, b) = input().split()
a = int(a)
b = int(b)
if a % (b * 2 + 1) == 0:
	print(a // (b * 2 + 1))
else:
	print(a // (b * 2 + 1) + 1)


import sys
sys.setrecursionlimit(10 ** 9)

def int1(x):
	return int(x) - 1

def II():
	return int(input())

def MI():
	return list(map(int, input().split()))

def MI1():
	return list(map(int1, input().split()))

def LI():
	return list(map(int, input().split()))

def LI1():
	return list(map(int1, input().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def MS():
	return input().split()

def LS():
	return list(input())

def LLS(rows_number):
	return [LS() for _ in range(rows_number)]

def printlist(lst, k=' '):
	print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
	(N, D) = MI()
	ans = 0
	while N > 0:
		N -= 1 + 2 * D
		ans += 1
	print(ans)

def __starting_point():
	solve()
__starting_point()


(N, D) = map(int, input().split())
M = 2 * D + 1
if N % M == 0:
	print(N // M)
else:
	print(N // M + 1)


(a, b) = map(int, input().split())
c = -(-a // (b * 2 + 1))
print(c)


import math
(n, k) = map(int, input().split())
print(math.ceil(n / (2 * k + 1)))


(N, M) = map(int, input().split())
chk = M * 2 + 1
print((N - 1) // chk + 1)


(A, B) = map(int, input().split())
print((A + 2 * B) // (2 * B + 1))


(N, D) = map(int, input().split())
import math
print(int(math.ceil(N / (2 * D + 1))))


(n, d) = map(int, input().split())
D = 2 * d + 1
print((n + D - 1) // D)


(n, d) = map(int, input().split())
print(n // (2 * d + 1) + bool(n % (2 * d + 1)))


(a, b) = map(int, input().split())
t = 2 * b + 1
print((a - 1) // t + 1)


x = list(map(int, input().split()))
print(-(-x[0] // (x[1] * 2 + 1)))


(n, m) = map(int, input().split())
print((n + 2 * m) // (2 * m + 1))


(n, d) = map(int, input().split())
p = -(-n // (1 + 2 * d))
print(p)


(n, d) = map(int, input().split())
di = 2 * d + 1
print(-(-n // di))


(n, d) = list(map(int, input().split()))
print(-(-n // (d * 2 + 1)))


(N, D) = map(int, input().split())
import numpy as np
print(int(np.ceil(N / (2 * D + 1))))


(N, D) = (int(a) for a in input().split())
print(-(-N // (D * 2 + 1)))


(N, D) = map(int, input().split())
area = D * 2 + 1
ans = (N + area - 1) // area
print(ans)


(n, b) = map(int, input().split())
print(-(-n // (b * 2 + 1)))


(n, k) = map(int, input().split())
d = 1 + k * 2
print((n + d - 1) // d)


(N, D) = map(int, input().split())
(monitor, ans) = (0, 0)
while monitor < N:
	monitor += 2 * D + 1
	ans += 1
print(ans)


import math
(N, D) = list(map(int, input().split()))
num = math.floor(N / (D * 2 + 1))
if N % (D * 2 + 1) != 0:
	print(num + 1)
else:
	print(num)


(a, b) = list(map(int, input().split()))
ans = a // (b * 2 + 1)
if ans == a / (b * 2 + 1):
	print(ans)
else:
	print(ans + 1)


(n, d) = map(int, input().split())
print((n + d + d) // (d + d + 1))


(s1, s2) = input().split()
N = int(s1)
D = int(s2)
print((N + 2 * D) // (2 * D + 1))


(N, D) = map(int, input().split())
for n in range(1, 25):
	if N <= (2 * D + 1) * n:
		print(n)
		break


a = list(map(int, input().split()))
print(-(-a[0] // (2 * a[1] + 1)))


(n, d) = map(int, input().split())
watch = d * 2 + 1
print(-(-n // watch))


import math
(n, d) = map(int, input().split())
print(math.ceil(n / (d * 2 + 1)))


(n, d) = map(int, input().split())
num = 2 * d + 1
print((n - 1) // num + 1)


from math import ceil
(a, b) = map(int, input().split())
print(ceil(a / (b * 2 + 1)))


(N, D) = map(int, input().split())
from numpy import ceil
print(int(ceil(N / (2 * D + 1))))


A = list(map(int, input().split()))
print((A[0] - 1) // (1 + 2 * A[1]) + 1)


(a, b) = [int(i) for i in input().split()]
print(-(-a // (2 * b + 1)))


(a, b) = map(int, input().split())
b2 = b * 2 + 1
print(-(-a // b2))


(n, d) = map(int, input().split())
res = 2 * d + 1
print(-(-n // res))


(N, D) = map(int, input().split())
moniter = D * 2 + 1
if N <= moniter:
	print(1)
elif N % moniter == 0:
	print(N // moniter)
else:
	print(N // moniter + 1)


(n, d) = map(int, input().split())
r = d * 2 + 1
print(-(-n // r))


(n, d) = (int(i) for i in input().split())
print((n - 1) // (d * 2 + 1) + 1)


(N, D) = [int(i) for i in input().split()]
print(-(-N // (2 * D + 1)))


(n, d) = map(int, input().split())
c = 2 * d + 1
print(-(-n // c))


(N, D) = map(int, input().split())
a = D * 2 + 1
ans = -(-N // a)
print(ans)


(n, d) = map(int, input().split())
rng = 1 + 2 * d
print((n + rng - 1) // rng)


(i, d) = list(map(int, input().split()))
a = d * 2 + 1
print((i + a - 1) // a)


(N, D) = map(int, input().split())
n_list = []
for i in range(1, N + 1):
	n_list.append(i)
num = len(n_list) % (2 * D + 1)
if num == 0:
	print(len(n_list) // (2 * D + 1))
else:
	print(len(n_list) // (2 * D + 1) + 1)


(a, s) = map(int, input().split())
print(-(-a // (2 * s + 1)))


(a, b) = list(map(int, input().split()))
print(int((a - 1) / (2 * b + 1)) + 1)


(n, d) = list(map(int, input().split()))
if n // (2 * d + 1) == n / (2 * d + 1):
	print(n // (2 * d + 1))
else:
	print(n // (2 * d + 1) + 1)


(n, d) = map(int, input().split())
t = d * 2 + 1
print((n + t - 1) // t)


r = input().split()
N = int(r[0])
D = int(r[1])
if N % (2 * D + 1) == 0:
	print(N // (2 * D + 1))
else:
	print(N // (2 * D + 1) + 1)


(N, D) = map(int, input().split())
R = N % (2 * D + 1)
if R != 0:
	L = (N - R) / (2 * D + 1) + 1
else:
	L = N / (2 * D + 1)
print(int(L))


import math
(a, b) = map(int, input().split())
print(math.ceil(a / (b + b + 1)))


a = list(map(int, input().split()))
N = a[0]
D = a[1]
z = N // (2 * D + 1)
if N % (2 * D + 1) == 0:
	print(z)
else:
	print(z + 1)


3
import sys
input = lambda : sys.stdin.readline().strip()
(n, d) = [int(x) for x in input().split()]
l = 2 * d + 1
print((n + l - 1) // l)


(n, d) = [int(i) for i in input().split()]
ans = n // (2 * d + 1)
ans = ans if n % (2 * d + 1) == 0 else ans + 1
print(ans)


(a, b) = map(int, input().split())
h = -(-a // (2 * b + 1))
print(h)


(N, D) = map(int, input().split())
a = 2 * D + 1
if N % a == 0:
	ans = N // a
else:
	ans = N // a + 1
print(ans)


(n, d) = [int(x) for x in input().split()]
if n % (2 * d + 1) == 0:
	print(n // (2 * d + 1))
else:
	print(n // (2 * d + 1) + 1)


from math import floor, ceil
(N, D) = list(map(int, input().split()))
print(ceil(N / (2 * D + 1)))


(N, D) = map(int, input().split())
hani = N + D - (N - D) + 1
import math
print(math.ceil(N / hani))


(N, D) = map(int, input().split())
r = 2 * D + 1
ans = -N // r
print(-ans)


(n, d) = map(int, input().split())
kanshi = 2 * d + 1
print(-(-n // kanshi))


(N, D) = map(int, input().split())
A = D * 2 + 1
print(N // A + (N % A != 0))


(n, d) = map(int, input().split())
print(0 - -n // (d - ~d))


import math
(tree_num, range) = list(map(int, input().split()))
range_num = range * 2 + 1
print(math.ceil(tree_num / range_num))


(N, D) = [int(n) for n in input().split()]
print((N - 1) // (2 * D + 1) + 1)


(n, d) = map(int, input().split())
e = d * 2 + 1
print(-(-1 * n // e))


(n, d) = (int(x) for x in input().split())
print(-(-n // (2 * d + 1)))


(n, d) = map(int, input().split())
i = 1
d = 2 * d + 1
while n > d * i:
	i += 1
print(i)


(N, D) = map(int, input().split())
if N % (2 * D + 1):
	print(N // (2 * D + 1) + 1)
else:
	print(N // (2 * D + 1))


(n, d) = list(map(int, input().split(' ')))
d = d * 2 + 1
answer = 0
while n > 0:
	n -= d
	answer += 1
print(answer)


(N, D) = [int(v) for v in input().split()]
ans = int(N / (2 * D + 1)) + int(N % (2 * D + 1) != 0)
print(ans)


(n, d) = [int(_) for _ in input().split()]
s = 2 * d + 1
print(-(-n // s))


(a, b) = map(int, input().split())
x = 2 * b + 1
print(a // x + 1 * bool(a % x))


import math
(x, y) = map(int, input().split())
print(math.ceil(x / (y + y + 1)))


(N, D) = map(int, input().split())
for i in range(20):
	if 2 * D * i + i >= N:
		print(i)
		return


(a, b) = map(int, input().split())
b = b * 2 + 1
c = 0
while a > 0:
	a -= b
	c += 1
print(c)


import math
(n, d) = (int(i) for i in input().split())
print(math.ceil(n / (d * 2 + 1)))