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 3 years have passed since last update.

パナソニックプログラミングコンテスト (AtCoder Beginner Contest 186) 参戦記

Last updated at Posted at 2020-12-19

パナソニックプログラミングコンテスト (AtCoder Beginner Contest 186) 参戦記

ABC186A - Brick

1分で突破. 書くだけ.

N, W = map(int, input().split())

print(N // W)

ABC186B - Blocks on Grid

2分で突破. 書くだけ.

H, W, *A = map(int, open(0).read().split())

print(sum(A) - min(A) * H * W)

ABC186C - Unlucky 7

4分で突破. Python は oct 関数で8進数の文字列に変換できるので、それを使うと楽.

N = int(input())

result = 0
for i in range(1, N + 1):
    if oct(i).count('7') + str(i).count('7') == 0:
        result += 1
print(result)

ABC186D - Sum of difference

12分半で突破. Aの順序は変えても答えに影響はないので、ソートしてしまえば絶対値が外せる. 後は合計を使って O(N) に落とせば解ける.

N, *A = map(int, open(0).read().split())

A.sort()
s = sum(A)
result = 0
for i in range(N):
    a = A[i]
    s -= a
    result += s - a * (N - i - 1)
print(result)

ABC186E - Throne

突破できず. O(1) ないし、O(logN) で回数計算する方法が思いつかず.

ABC186F - Rook on Grid

突破できず. E問題を完全に捨てて、こっちに注力したら解けたかもしれない.

0
0
0

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?