AtCoder Beginner Contest 088

はい。
https://atcoder.jp/contests/abc088

A - Infinite Coins

Python3

n=int(input())
print("No" if  n%500>int(input()) else "Yes")

500円未満の端数をA枚の1円で大丈夫だと思う。。

B - Card Game for Two

Pyhthon3

n=int(input())
l=[int(i) for i in input().split()]
ans=sum(l)
l.sort()
for i in range(-2,-n-1,-2):
    ans-=l[i]*2
print(ans)

総和に対して降順の2番目から2個とばしで引いていくとAliceとBobの差分になるはず、多分

C - Takahashi's Information

Pyhthon3

a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
print("Yes" if a[0]-b[0]==a[1]-b[1]==a[2]-b[2] and a[0]-c[0]==a[1]-c[1]==a[2]-c[2] else "No")

それぞれの値を特定するのとても難しいのでは???と思ってたけど特定する必要はなくて差分に法則性があるので法則が乱れるかどうかを確認すれば大丈夫だと思う。多分。

D - Grid Repainting

Pyhthon3

xy=[(1,0),(-1,0),(0,1),(0,-1)]
ans=chk=0
h,w=map(int,input().split())
d=[[0]*w for i in range(h)]
l=[]
for i in range(h):
    a=input()
    chk+=a.count("#")
    l.append(a)
p=set([(0,0)])
while len(p):
    a,b=p.pop()
    for y,x in xy:
        y+=a
        x+=b
        if 0<=y<h and 0<=x<w and l[y][x]!="#":
            if d[y][x]==0 or d[y][x]>d[a][b]+1:
                d[y][x]=d[a][b]+1
                p.add((y,x))
 
print(-1 if d[h-1][w-1]==0 else h*w-1-chk-d[h-1][w-1])

問題文とサンプル1を信じる。0,0からH,Wへ移動するのに通過しないマスを全て"#"にしたい。なので最短の移動回数を調べる。白マスしか通過しないので経路は復元する必要ないです。H,Wまで移動出来たら通過したトコと0,0、H,W、入力受取時に既に”#”のトコ以外は全て変更できるのでソレが解になります。多分。