강의

멘토링

커뮤니티

Inflearn Community Q&A

heewon2218921's profile image
heewon2218921

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

6. Maximum grid sum

5번 틀림

Written on

·

94

0

5번만 틀렸는데, 어느부분에서 틀렸는지 모르겠습니다.. 알려주세요 .. 아래는 제가 짠 코드입니다

n = int(input())

max = -1

tot,tto = 0,0

li = [[0]*n for _ in range(n)] # n의 크기를 가지고 0으로초기화된 리스트를 n번 반복

for i in range(n):

li[i]= list(map(int, input().split()))

for i in range(n):

if sum(li[i]) > max:

max = sum(li[i])

for j in range(n):

for i in range(n):

tot += li[i][j]

tot = 0

if tot > max:

max = tot

for i in range(n):

tot += li[i][i]

tto += li[i][n-i-1]

if tot > max:

max = tot

if tto > max:

max = tto

print(max)

python코딩-테스트

Answer

This question is waiting for answers
Be the first to answer!
heewon2218921's profile image
heewon2218921

asked

Ask a question