0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ABC129復習

Posted at

A-AirPlane
https://atcoder.jp/contests/abc129/tasks/abc129_a
(方針)無題.png

A,B,Cそれぞれの空港から出発するとかかる時間はp+q,q+r,r+pとなるのでこの3つのうちの最小値を出力する。

airplane.py
p,q,r=map(int,input().split(" "))
a=p+q
b=q+r
c=r+p
l=[a,b,c]
l.sort()
print(l[0])

B-Balance
https://atcoder.jp/contests/abc129/tasks/abc129_b
(方針)n最大100なので全部のパターンを試していけばよい。

b.py
def sum(l):
    a=0
    for i in range(len(l)):
        a+=l[i]
    return a
n=int(input())
result=[]
w=(input()).split(" ")
w=[int(k) for k in w]
for i in range(1,n,1):#n-1回ループ
    wa=abs(sum(w[i:])-sum(w[:i]))
    result.append(wa)
print(min(result))

C-Typical Stairs
https://atcoder.jp/contests/abc129/tasks/abc129_c
(方針)https://youtu.be/L8grWxBlIZ4?t=2551
初めてのdp(動的計画法)。数列漸化式みたいなもん
DAGの説明も読もうhttps://youtu.be/L8grWxBlIZ4?t=3759

c.py
n,m=map(int,input().split(" "))
l=[None for k in range(n+2)]
l[n]=1
l[n+1]=0
for i in range(m):
    l[int(input())]=0
for i in range(n-1,-1,-1):
    if l[i]==None:
        l[i]=l[i+1]+l[i+2]
print(l[0]%1000000007)

D-Lamp
https://atcoder.jp/contests/abc129/tasks/abc129_d
(方針)横と縦を分けて考える。計算量の関係からnumpyをつかう
実装できなかったので後日
まずはDまで解けるようにしたい

d.py

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?