Data Structures & Algorithms

[Algorithms] Basic-사과나무(다이아몬드)

숄구-ml 2022. 5. 14. 15:18

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sys
 
sys.stdin = open("input""rt")
= int(input())
ar = [list(map(int, input().split())) for _ in range(n)]
 
= e = n//2
apple=0
 
for i in range(n):
    for j in range(s, e+1):
        apple += ar[i][j]
 
    if i < n//2:
        s-=1
        e+=1
    else:
        s+=1
        e-=1
 
print(apple)
cs

 

 

728x90