이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
from sys import stdin
input = stdin.readline
L, N = map(int, input().split())
arr = [map(int, input().split()) for i in xrange(N)]
arr.sort()
brr = [float(L) / j + i for i, j in arr][::-1]
# count LIS
def lis(n, arr, output = False):
d = [0] * (n + 1)
p = [0] * (n + 1)
L = 0
for i in xrange(n):
low = 1
high = L
while low <= high:
mid = (low + high) / 2
if arr[d[mid]] < arr[i]: low = mid + 1
else: high = mid - 1
p[i] = d[low - 1]
d[low] = i
L = max(L, low)
print L
if output:
ans = []
k = d[L]
for i in xrange(L):
ans.append(arr[k])
k = p[k]
print " ".join(map(str, ans[::-1]))
lis(N, brr)
# | 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... |