feat: added alternative python solutions.

This commit is contained in:
2026-05-17 13:20:58 -03:00
parent 7e9caaea6e
commit c85571e157
451 changed files with 3777 additions and 3495 deletions

View File

@@ -43,7 +43,7 @@
},
"solutions": {
"main-ac": "ac.cpp",
"alternative-ac": [],
"alternative-ac": ["alternative-ac.py"],
"wrong-answer": [],
"time-limit": ["TLE.cpp"],
"time-limit-or-ac": [],

View File

@@ -0,0 +1,34 @@
import bisect
n = int(input())
a = list(map(int, input().split()))
tails = []
tail_indices = []
parent = [-1] * n
for i in range(n):
pos = bisect.bisect_left(tails, a[i])
if pos > 0:
parent[i] = tail_indices[pos - 1]
if pos == len(tails):
tails.append(a[i])
tail_indices.append(i)
else:
tails[pos] = a[i]
tail_indices[pos] = i
max_length = len(tails)
lis = []
if max_length > 0:
idx = tail_indices[-1]
while idx != -1:
lis.append(a[idx])
idx = parent[idx]
lis.reverse()
print(max_length)
print(' '.join(map(str, lis)))