이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
def find_max_islands(lst):
    i = 1  #this code is to remove adjacent same island heights
    temp=-1
    lst3=[]
    for i in lst:
        if i!=temp:
            lst3+=[i]
        temp=i
    lst2 = []+lst
    lst2.sort()#sort list in descending order to flood the islands
    lst2.reverse()
    lst3 = []+lst2
    peakvalley = []
    count = 0
    islands=[]
    for i in range(len(lst3)):
        x = lst.index(lst3[i]) #identify where the island height is in original list
        if x==len(lst)-1: #if i is the last element in the list
            if lst[x]>lst[x-1]: 
                islands.append(1)
            continue
        if x == 0: #if i is the first element in the list
            if lst[x]>lst[x+1]:
                islands.append(1)
            continue
        if lst[x]>lst[x+1]and lst[x]>lst[x-1]: #if island is higher than those around it
                islands.append(1)
        if lst[x]<lst[x+1]and lst[x]<lst[x-1]: #if island is lower than those around it
                islands.append(-1)
    maxisle = 0
    count = 0
    d=0
    for i in islands:
        count+=i
        d=max(count,d)
    return d
from sys import stdin,stdout
n=int(stdin.readline())
lst=[]
for i in range(n):
    lst+=[int(stdin.readline())]
stdout.write(str(find_max_islands(lst)))
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |