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?

「AtCoder Beginner Contest 186 B - Blocks on Grid」メモ

Posted at

問題

AtCoder Beginner Contest 186

考察

二次元配列を次のコードで入力から受け取る

a = [list(map(int, input().split())) for _ in range(h)]

二次元配列の最小値を求めて、それより大きい数からそれを引けばよい。

ACコード

def minimum(a, h, w):
    ans = 10**9
    for i in range(h):
        for j in range(w):
            if a[i][j] < ans:
                ans = a[i][j]
    return ans

h,w=map(int,input().split())

a = [list(map(int, input().split())) for _ in range(h)]

ans = 0
for i in range(h):
    for j in range(w):
        ans += a[i][j] - minimum(a, h, w)

print(ans)
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?