A.py
X, Y = map(int, input().split())
if max(X, Y) - min(X, Y) < 3:
print("Yes")
else:
print("No")
B.py
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
ans += A[i]*B[i]
if ans == 0:
print('Yes')
else:
print('No')
C.py
N = int(input())
A = list(map(int, input().split()))
l = [A]
for i in range(1, N+1):
# print('---')
a = []
for j in range(1, 2**(N-i)+1):
# print(j*2-1, j*2)
a.append(max(l[i-1][j*2-1-1], l[i-1][j*2-1]))
l.append(a)
p = min(l[-2][0], l[-2][1])
print(A.index(p)+1)
D.py
N, C = map(int, input().split())
event = []
for i in range(N):
a, b, c = map(int, input().split())
a -= 1
event.append([a, c])
event.append([b, -c])
event.sort()
# print(event)
ans = 0
fee = 0
t = 0
for x, y in event:
if x != t:
ans += min(C, fee) * (x - t)
t = x
fee += y
print(ans)
Recommended Posts