-
Notifications
You must be signed in to change notification settings - Fork 0
/
[swea] 1208. [SW 문제해결 기본] 1일차 - View.py
48 lines (40 loc) · 1.29 KB
/
[swea] 1208. [SW 문제해결 기본] 1일차 - View.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
for test_case in range(1, 11):
a = int(input())
n = list(map(int, input().split()))
sum = 0
for i in range(a-5):
arr = n[i:i+5]
middle = arr[2]
arr.remove(middle)
if middle - max(arr) > 0:
sum = sum + (middle - max(arr))
arr = n[-1:-6:-1]
middle = arr[2]
arr.remove(middle)
if middle - max(arr) > 0:
sum = sum + (middle - max(arr))
print("#{} {}".format(test_case, sum))
-----------------------------------------------
for test_case in range(1, 11):
a = int(input())
n = list(map(int, input().split()))
sum = 0
for i in range(2, a-2):
view1 = n[i]-n[i-2]
view2 = n[i]-n[i-1]
view3 = n[i]-n[i+1]
view4 = n[i]-n[i+2]
if view1 > 0 and view2 > 0 and view3 > 0 and view4 > 0 :
sum = sum + min(view1, view2, view3, view4)
print("#{} {}".format(test_case, sum))
--------------------------------------------------
2023.05.06
for test_case in range(1, 11):
a = int(input())
answer = 0
n = list(map(int, input().split()))
for i in range(2, len(n)-2):
if n[i-2] > n[i] or n[i-1] > n[i] or n[i+1] > n[i] or n[i+2] > n[i]:
continue
answer += n[i] - max(n[i-2], n[i-1], n[i+1], n[i+2])
print("#{} {}".format(test_case, answer))