Submission #335608

#TimeUsernameProblemLanguageResultExecution timeMemory
335608beepbeepsheepGlobal Warming (NOI13_gw)Cpython 3
6 / 40
1099 ms65536 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...