def binary_search(t, l, r, key): while (r - l > 1): m = l + (r - l)//2 if (t[m]>=key): r = m else: l = m return r def LIS(): tailTable = [0] * N tailTable[0] = lst[0] len = 1 for i in range(1, N): if (lst[i] < tailTable[0]): # New Smallest Value tailTable[0] = lst[i] elif (lst[i] > tailTable[len - 1]): # lst[i] wants to extend largest subsequence tailTable[len] = lst[i] len += 1 else: # A[i] wants to be current end candidate of an existing # subsequence. tailTable[binary_search(tailTable, -1, len-1, lst[i])] = lst[i] return len if __name__ == "__main__": N = int(input()) lst = [] for i in range(N): lst.append(input()) ret = LIS() print(ret)
def LIS(): lenmax = 1 len = 1 for i in range(1, N): if (lst[i-1] < lst[i]): # in sequence len += 1 if (len > lenmax): lenmax = len else: # new sequence len = 1 return lenmax
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)