Daily AtCoder # 28 in Python

Introduction

Last time Today I solved the problem of ABC140. It was A ~ C in 50 minutes.

A problem

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)

B problem

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)

C problem

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)

Summary

D (1110diff) could not be solved. It is regrettable that C also struggled for the diff. see you. good night.

Recommended Posts

Daily AtCoder # 36 in Python
Daily AtCoder # 2 in Python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Daily AtCoder # 53 in Python
Daily AtCoder # 33 in Python
Daily AtCoder # 7 in Python
Daily AtCoder # 24 in Python
Daily AtCoder # 37 in Python
Daily AtCoder # 42 in Python
Daily AtCoder # 21 in Python
Daily AtCoder # 17 in Python
Daily AtCoder # 38 in Python
Daily AtCoder # 54 in Python
Daily AtCoder # 11 in Python
Daily AtCoder # 15 in Python
Daily AtCoder # 47 in Python
Daily AtCoder # 13 in Python
Daily AtCoder # 40 in Python
Daily AtCoder # 10 in Python
Daily AtCoder # 5 in Python
Daily AtCoder # 28 in Python
Daily AtCoder # 39 in Python
Daily AtCoder # 20 in Python
Daily AtCoder # 19 in Python
Daily AtCoder # 52 in Python
Daily AtCoder # 3 in Python
Daily AtCoder # 14 in Python
Daily AtCoder # 50 in Python
Daily AtCoder # 26 in Python
Daily AtCoder # 4 in Python
Daily AtCoder # 43 in Python
Daily AtCoder # 29 in Python
Daily AtCoder # 22 in Python
Daily AtCoder # 49 in Python
Daily AtCoder # 27 in Python
Daily AtCoder # 1 in Python
Daily AtCoder # 25 in Python
Daily AtCoder # 16 in Python
Daily AtCoder # 12 in Python
Daily AtCoder # 48 in Python
Daily AtCoder # 23 in Python
Daily AtCoder # 34 in Python
Daily AtCoder # 51 in Python
Daily AtCoder # 31 in Python
Daily AtCoder # 46 in Python
Daily AtCoder # 35 in Python
Daily AtCoder # 9 in Python
Daily AtCoder # 44 in Python
Daily AtCoder # 41 in Python
Atcoder ABC164 A-C in Python
atCoder 173 Python
Python Input Note in AtCoder
Atcoder ABC167 A-D in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
Solve Atcoder ABC169 A-D in Python
[Python] Basic knowledge used in AtCoder