Submission #335608

# Submission time Handle Problem Language Result Execution time Memory
335608 2020-12-13T09:17:39 Z beepbeepsheep Global Warming (NOI13_gw) Python 3
6 / 40
1000 ms 65536 KB
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
1 Correct 25 ms 3052 KB Output is correct
2 Correct 25 ms 2924 KB Output is correct
3 Correct 25 ms 2924 KB Output is correct
4 Correct 25 ms 2924 KB Output is correct
5 Correct 26 ms 3052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 216 ms 6356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 10160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -