LoginSignup
0
0

More than 1 year has passed since last update.

Atcoder B - Nice Shopping

Last updated at Posted at 2022-04-21

問題

回答

A,B,M = map(int,input().split())
a = list(map(int,input().split()))#冷蔵庫
b = list(map(int,input().split()))#電子レンジ
ans = min(a) + min(b)
 
for i in range(M):
  x,y,c = map(int,input().split())
  num = a[x-1] + b[y-1] - c
  if ans > num:
    ans = num
 
print(ans)

または

A,B,M = map(int,input().split())
a = list(map(int,input().split()))#冷蔵庫
b = list(map(int,input().split()))#電子レンジ
ans = min(a)+min(b)
for i in range(M):
    x, y, c = map(int,input().split())

    ans = min(ans,a[x-1]+b[y-1]-c)
 
print(ans)

ポイント

for文の中でx, y, c = map(int,input().split())の標準入力を記載すること」。これが思いつかず。

0
0
1

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