Last time Today I solved the problem of ABC140. It was A ~ C in 50 minutes.
Problem 0diff
** Thoughts ** Since it is a 3-digit password, you can output the cube of the number that can be used.
n = int(input())
print(n**3)
Problem 58diff
** Thoughts ** Just calculate with for statement and if statement. Be careful not to mix the elements of the list with the index
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
f = 10**9
for i in range(n):
ans += b[a[i]-1]
if a[i] - f == 1:
ans += c[a[i-1]-1]
f = a[i]
print(ans)
Problem 136diff
** Thoughts ** The sum of the elements of $ A $ is maximized when the elements of $ A $ given by $ B $ are maximized. The maximum is when $ a [0] $ has the same value as $ b [0] $ and $ a [-1] $ has the same value as $ b [-1] $. The other $ A $ is determined by min (b [i-1], b [i]).
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
f = 10**9
for i in range(n):
ans += b[a[i]-1]
if a[i] - f == 1:
ans += c[a[i-1]-1]
f = a[i]
print(ans)
D (1110diff) could not be solved. It is regrettable that C also struggled for the diff. see you. good night.
Recommended Posts