ZhenlongDai/ACPR huggingface dataset:
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
a.reverse()
b = [a[0]]
counter = 1
for i in range(1,n):
    if a[i] >= b[-1]:
        counter += 1
        b.append(a[i])
    else:
        ind = bisect.bisect_left(b,a[i])
        b[ind] = a[i]
print(counter)

Failing test case input:
5
0
0
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
a.reverse()
b = [a[0]]
counter = 1
for i in range(1,n):
    if a[i] >= b[-1]:
        counter += 1
        b.append(a[i])
    else:
        ind = bisect.bisect_right(b,a[i])
        b[ind] = a[i]
print(counter)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

ans = deque()
ans.append(A[0])

for a in A[1:]:
  if a <= ans[0]:
    ans.appendleft(a)
  elif a > ans[-1]:
    ans[-1] = a
  else:
    i = bisect.bisect_left(ans, a)
    ans[i] = a

print(len(ans))


Failing test case input:
5
4
1
4
17
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import deque
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

ans = deque()
ans.append(A[0])

for a in A[1:]:
  if a <= ans[0]:
    ans.appendleft(a)
  elif a > ans[-1]:
    ans[-1] = a
  else:
    i = bisect.bisect_left(ans, a)
    ans[i - 1] = a

print(len(ans))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n = int(input())
c = [int(input())]
for i in range(n-1):
  a = int(input())
  if c[0] >= a:
    c.append(a)
  else:
    c[bisect.bisect_right(c,a)-1] = a
print(len(c))

Failing test case input:
5
3
0
1
2
0

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a = [int(input()) for i in range(n)]
c = [a[-1]]
for i in a[n-2::-1]:
  if c[-1] <= i:
    c.append(i)
  else:
    c[bisect.bisect_left(c,i+1)] = i
  
print(len(c))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import bisect

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = [A[0]]
    for a in A[1:]:
        if a <= arr[0]:
            arr.insert(0,a)
        else:
            insert_index = bisect.bisect_right(arr, a)
            update = min(len(arr)-1, insert_index+1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()

Failing test case input:
5
4
-1
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
import bisect
from collections import deque

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = deque()
    arr.append(A[0])
    for a in A[1:]:
        if a <= arr[0]:
            arr.appendleft(a)
        else:
            insert_index = bisect.bisect_left(arr, a)
            update = max(0, insert_index-1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [-int(input()) for _ in range(N)]
tmp = [A[0]]
for i in A[1:N]:
    index = bisect.bisect_left(tmp, i)
    if index == 0:
        tmp.append(i)
    else:
        tmp[index-1] = i

print(len(tmp))


Failing test case input:
5
11
-1
1
13
5

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [-int(input()) for _ in range(N)]
tmp = [A[0]]
for i in A[1:N]:
    index = bisect.bisect(tmp, i)
    if index == len(tmp):
        tmp.append(i)
    else:
        tmp[index] = i

print(len(tmp))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque

n = int(input())
L = deque([int(input())])
for i in range(1,n):
    t = int(input())
    a = L.popleft()
    if t <= a:
        L.append(t)
        L.append(a)
    else:
        L.append(t)
print(len(L))


Failing test case input:
5
12
1
6
9
4

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
from collections import deque
import bisect
n = int(input())
L = deque([int(input())])
for i in range(1,n):
    t = int(input())
    k = bisect.bisect_left(L, t)
    if k == 0:
        L.appendleft(t)
    else:
        L[k-1] = t
print(len(L))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def lis(A: "Array[int]") -> int:
    from bisect import bisect_left

    
    dp = [A[0]]
    for i in A[1:]:
        if i > dp[-1]:
            dp.append(i)
        else:
            dp[bisect_left(dp, i)] = i
    return len(dp)


def main():
    N, *A = map(int, open(0).read().split())
    ans = lis([-i for i in A])  
    print(ans)


if __name__ == "__main__":
    main()

Failing test case input:
5
0
1
1
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

def lis(A: "Array[int]") -> int:
    from bisect import bisect_right

    
    dp = [A[0]]
    for i in A[1:]:
        if i >= dp[-1]:
            dp.append(i)
        else:
            dp[bisect_right(dp, i)] = i
    return len(dp)


def main():
    N, *A = map(int, open(0))
    ans = lis(A[::-1])  
    print(ans)


if __name__ == "__main__":
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

import bisect

color = []
color.append(a.pop(0))
color_count =0 
for i, ai in enumerate(a): 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.append(ai)
print(len(color))

Failing test case input:
5
1
0
2
1
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left

N = int(input())
Alist = [int(input()) for i in range(N)]

num_col = 1
L = [-1*Alist[0]] 
for ai in Alist[1:]:
    ai = -1*ai
    if ai > L[-1]:
        L.append(ai)
        num_col += 1
    else:
        L[bisect_left(L, ai)] = ai
print(num_col)

Failing test case input:
5
10
-1
2
2
0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from bisect import bisect_right
N = int(input())
Alist = [int(input()) for i in range(N)]

num_col = 1
L = [-1*Alist[0]] 
for ai in Alist[1:]:
    
    ai =-1*ai
    if ai >= L[-1]:
        L.append(ai)
        num_col += 1
    else:
        L[bisect_right(L, ai)] = ai
print(num_col)

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]

LIS = [a[-1]]
for i in range(n - 2, -1, -1):
    if a[i] >= LIS[-1]:
        LIS.append(a[i])
    else:
        LIS[bisect.bisect_left(LIS, a[i])] = a[i]

print(len(LIS))


Failing test case input:
5
0
0
0
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]

LIS = [a[-1]]
for i in range(n - 2, -1, -1):
    if a[i] >= LIS[-1]:
        LIS.append(a[i])
    else:
        LIS[bisect.bisect_right(LIS, a[i])] = a[i]

print(len(LIS))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
m=10**10
ans=0
for i in range(n):
    a=int(input())
    if a<=m:
        m=a
        ans+=1
print(ans)

Failing test case input:
5
12
0
5
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=deque([])
for i in range(n):
    a=int(input())
    ind=bisect.bisect_right(l,a-1)
    if ind==0:
        l.appendleft(a)
    else:
        l[ind-1]=a
print(len(l))

Problem: p02973
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def LIS(l):
    from bisect import bisect_left
    dp = [l[0]+1]
    for i in range(len(l)):
        if l[i] >= dp[-1]:
            dp.append(l[i])
        else:
            dp[bisect_left(dp, l[i])] = l[i]
    return len(dp)
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(LIS(a[::-1]))
main()

Failing test case input:
5
0
0
0
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
def LIS(l):
    from bisect import bisect_right
    dp = [l[0]+1]
    for i in range(len(l)):
        if l[i] >= dp[-1]:
            dp.append(l[i])
        else:
            dp[bisect_right(dp, l[i])] = l[i]
    return len(dp)
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(LIS(a[::-1]))
main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from bisect import bisect_right

def main():
    input = sys.stdin.readline
    N = int(input())
    q = list(map(int, input().split()))

    min_ = q[0]
    max_ = q[0]

    for _ in range(N-1):
        a = int(input())
        if a <= min_:
            q = [a] + q
            min_ = a
            continue
        if a > max_:
            q[-1] = a
            max_ = a
            continue

        pos = bisect_right(q, a)
        q = q[0:pos-1] + [a] + q[pos:]
        min_ = q[0]

    return len(q)


if __name__ == '__main__':
    print(main())


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
from collections import deque
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


if __name__ == '__main__':
    print(main())
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
N=int(input())
A=[int(input()) for _ in range(N)]
color=[]
A=A[::-1]
for a in A:
    i=bisect.bisect_left(color,a)
    if i==len(color):
        color.append(a)
    else:
        color[i]=a
print(len(color))

Failing test case input:
5
1
0
1
1
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N=int(input())
A=[int(input()) for _ in range(N)]
color=[]
A=A[::-1]
for a in A:
    i=bisect.bisect_right(color,a)
    if i==len(color):
        color.append(a)
    else:
        color[i]=a
print(len(color))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import bisect

n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = int(input())


LIS = list()
for i in a:
    j = bisect.bisect_right(LIS, i)
    if len(LIS) <= j:
        LIS.append(i)
    else:
        LIS[j] = i

print(len(LIS))

Failing test case input:
5
4
1
4
5
9

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):

import bisect

n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = -int(input())


LIS = list()
for i in a:
    j = bisect.bisect_right(LIS, i)
    if len(LIS) == j:
        LIS.append(i)
    else:
        LIS[j] = i

print(len(LIS))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import bisect

N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    if len(B) == 0:
        B.append(A[i])
    else:
        if B[0] >= A[i]:
            B.append(A[i])
        else:
            index = bisect.bisect_left(B,A[i])-1
            B[index] = A[i]
    B.sort()
print(len(B)+1)

Failing test case input:
5
0
0
-1
7
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):

import heapq
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
A = A[::-1]

C = []
for i in range(N):
    if i == 0:
        C.append(A[i])
    else:
        li = bisect.bisect_right(C,A[i])
        if li == len(C):
            C.append(A[i])
        else:
            C[li] = A[i]
    
print(len(C))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [-int(input()) for _ in range(N)]
tmp = [A[0]]
for i in A[1:N]:
    index = bisect.bisect(tmp, i)
    if index == 0:
        tmp.append(i)
    else:
        tmp[index-1] = i

print(len(tmp))


Failing test case input:
4
0
0
-1
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [-int(input()) for _ in range(N)]
tmp = [A[0]]
for i in A[1:N]:
    index = bisect.bisect(tmp, i)
    if index == len(tmp):
        tmp.append(i)
    else:
        tmp[index] = i

print(len(tmp))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
check = [0]*(N+1)
A = [int(input()) for _ in range(N)]
LIS = [INF]*(N+1)
for i in range(N):
    temp = bisect.bisect_left(LIS, A[i])
    check[temp] += 1
    LIS[temp] = A[i]
print(max(check))


Failing test case input:
5
4
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
A = [int(input()) for _ in range(N)]
Min = [A[-1]]
for i in range(N - 2, -1, -1):
    temp = bisect.bisect_right(Min, A[i])
    if temp == len(Min):
        Min.append(A[i])
    elif Min[temp] != A[i]:
        Min[temp] = A[i]
    elif temp + 1 != len(Min):
        Min[temp + 1] = A[i]
    else:
        Min.append(A[i])
print(len(Min))

Problem: p02973
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    now = 1
    for i in range(1, n):
        if a[i - 1] < a[i]:
            ans = max(ans, now)
            now = 1
        else:
            now += 1
    ans = max(ans, now)
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
5
7
1
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a.reverse()
    lis = [a[0]]
    for i in range(1, n):
        if a[i] >= lis[-1]:
            lis.append(a[i])
        else:
            lis[bisect_right(lis, a[i])] = a[i]
    print(len(lis))


if __name__ == '__main__':
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            i = bisect_left(L, a)
            L[i] = a
    print(len(L))


if __name__ == "__main__":
    main()


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect


def main():
    N = int(input())
    A = [-int(input()) for _ in range(N)]
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            L.append(a)
        else:
            L[bisect(L, a)] = a
    print(len(L))


if __name__ == "__main__":
    main()
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [int(input()) for i in range(N)]

dp = []
for a in A:
    i = bisect.bisect_right(dp, a)
    if i >= len(dp):
        dp.append(a)
    else:
        dp[i] = a

print(N-len(dp))

Failing test case input:
5
0
0
-1
0
0

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [-int(input()) for i in range(N)]


dp = []
for a in A:
    i = bisect.bisect_right(dp, a)
    if i >= len(dp):
        dp.append(a)
    else:
        dp[i] = a

print(len(dp))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]


colors = []
cmt = 0

for i,n in enumerate(list(reversed(A))):
    
    if i == 0:
        colors.append(n)
    else:
        
        idx = bisect.bisect_left(colors, n)
        if idx == len(colors):
            colors.append(n)
        else:
            if colors[idx] == n:
                colors.insert(idx, n)
            else:
                colors[idx] = n

print(len(colors))

Failing test case input:
4
0
0
1
0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]


colors = []


for i,n in enumerate(list(reversed(A))):
    
    if i == 0:
        colors.append(n)
    else:
        
        
        
        idx = bisect.bisect_right(colors, n)
        if idx == len(colors):
            colors.append(n)
        else:
            colors[idx] = n

print(len(colors))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left as left 
import sys
readline = sys.stdin.buffer.readline

N = int(input())
A = [int(input()) for _ in range(N)]

INF = 10**10
dp = [INF] * (N+1)

answer = 0
for a in A:
  l = left(dp, a)
  if l == 0:
    answer += 1
  dp[l] = a
print(answer)

Failing test case input:
5
12
0
4
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right as right
import sys
readline = sys.stdin.buffer.readline

N = int(input())
A = [int(input()) for _ in range(N)][::-1]

INF = 10**10
dp = [INF] * (N+1)

answer = 0
for a in A:
  r = right(dp, a)
  if dp[r] > a:
    if dp[r] == INF:
      answer += 1
    dp[r] = a
print(answer)
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = [int(input()) for i in range(n)]
a = a[::-1]

from bisect import bisect_left


def lis(a):
    length = [a[0]]
    for i in range(1, len(a)):
        if a[i] >= length[-1]:
            length.append(a[i])
        else:
            length[bisect_left(length, a[i])] = a[i]
    return len(length)


print(lis(a))

Failing test case input:
5
1
0
0
5
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for i in range(n)]
a = a[::-1]

from bisect import bisect_left, bisect_right

def lis(a):
    length = [a[0]]
    for i in range(1, len(a)):
        if a[i] >= length[-1]:
            length.append(a[i])
        else:
            length[bisect_right(length, a[i])] = a[i]
    return len(length)


print(lis(a))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
Q = [-a[0]]
for i in range(1,n):
    if a[i] <= -Q[-1]:
        Q.append(-a[i])
    else:
        j = bisect.bisect_left(Q,-a[i])
        
        Q[j] = -a[i] 
    
print(len(Q))


Failing test case input:
5
4
1
4
17
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
Q = [-a[0]]
for i in range(1,n):
    if a[i] <= -Q[-1]:
        Q.append(-a[i])
    else:
        j = bisect.bisect_right(Q,-a[i])
        
        Q[j] = -a[i]
    
print(len(Q))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N=int(input())
A=[]
ans=0
for i in range(N):
    a=int(input())
    A.append(a)
cl=[A[-1]]
ans=1
for i in range(N-1)[::-1]:
    a=A[i]
    if a>=cl[-1]:
        cl.append(a)
        ans+=1
    else:
        b=bisect.bisect_left(cl,a)
        cl[b]=a
print(ans)

Failing test case input:
5
0
0
0
5
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N=int(input())
A=[]
ans=0
for i in range(N):
    a=int(input())
    A.append(a)
cl=[A[-1]]
ans=1
for i in range(N-1)[::-1]:
    a=A[i]
    if a>=cl[-1]:
        cl.append(a)
        ans+=1
    else:
        b=bisect.bisect_right(cl,a)
        cl[b]=a
print(ans)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [-A[0]]

for i in range(1, N):

    index = bisect.bisect_right(now, -A[i])
    if index == len(now):
        now.append(-A[i])
    else:
        now[index] = A[i]
print(len(now))



Failing test case input:
5
16
-1
1
2
2

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [-A[0]]

for i in range(1, N):

    index = bisect.bisect_right(now, -A[i])
    if index == len(now):
        now.append(-A[i])
    else:
        now[index] = -A[i]

print(len(now))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

n=int(input())
a=[int(input()) for x in range(n)]
c=[]

c.append(a[0])

for i in range(1,n):
  j=bisect.bisect_right(c,a[i])
  if c[j-1]<a[i]:
    c[j-1]=a[i]
  else:
    c.insert(j,a[i])
print(len(c))


Failing test case input:
5
4
1
4
5
9

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N=int(input())
A=[-int(input()) for i in range(N)]

B=[]
c=0
for a in A:
  p=bisect.bisect_right(B,a)
  if p==c:
    B.append(a)
    c += 1
  else:
    B[p]=a

print(len(B))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect


N = int(input())
A = [int(input()) for _ in range(N)]

L = []
L.append(A[0])
for i in range(1, N):
    if A[i] <= L[0]:
        L = [A[i]] + L
    elif A[i] > L[-1]:
        L[-1] = A[i]
    else:
        idx = bisect.bisect_left(L, A[i])
        L[idx] = A[i]
        
print(len(L))

Failing test case input:
5
10
-1
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

L = deque()
L.append(A[0])
for i in range(1, N):
    if A[i] <= L[0]:
        L.appendleft(A[i])
    elif A[i] > L[-1]:
        L[-1] = A[i]
    else:
        idx = bisect.bisect_left(L, A[i])
        L[idx-1] = A[i]
        
print(len(L))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N = int(input())
A = [-int(input()) for i in range(N)]

dp = []
for a in A:
    i = bisect.bisect_right(dp, a)
    if i >= len(dp):
        dp.append(a)
    else:
        dp[i] = a

print(N-len(dp))

Failing test case input:
5
10
-1
6
13
5

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
N = int(input())
A = [-int(input()) for i in range(N)]


dp = []
for a in A:
    i = bisect.bisect_right(dp, a)
    if i >= len(dp):
        dp.append(a)
    else:
        dp[i] = a

print(len(dp))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_right
N = int(input())
A = [int(input()) for _ in range(N)]

dp = [10**10] * N

for a in A:
    dp[bisect_right(dp, a)] = a

print(dp.count(10**10))


Failing test case input:
5
0
0
-1
7
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right
N = int(input())
A = [int(input()) for _ in range(N)]
dp = [10**10] * N
for a in A:
    a = -a
    dp[bisect_right(dp, a)] = a
ans = N - dp.count(10**10)
print(ans)
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

def LIS(A):
    
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_left(B, A[i+1])
            B[index] = A[i+1]
    return B

def LDS(A):
    
    A = A[::-1]
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_left(B, A[i+1])
            B[index] = A[i+1]
    return B[::-1]


print(len(LDS(A)))

Failing test case input:
5
0
0
0
7
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

def LIS(A):
    
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_left(B, A[i+1])
            B[index] = A[i+1]
    return B

def LDS(A):
    
    A = A[::-1]
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_right(B, A[i+1])
            B[index] = A[i+1]
    return B[::-1]


print(len(LDS(A)))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = 0
    min = float('inf')
    for ai in a:
        if ai <= min:
            ans += 1
            min = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Failing test case input:
5
10
-1
6
9
3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from sys import stdin, setrecursionlimit
from collections import deque
from bisect import bisect_left


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    ans = deque()
    for ai in a:
        idx = bisect_left(ans, ai)
        if idx == 0:
            ans.appendleft(ai)
        else:
            ans[idx - 1] = ai

    print(len(ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = [inp() for _ in range(N)]

tmp = deque([])
first = True

for a in aa:
    if first:
        tmp.append(a)
        first = False
        continue

    if tmp[0] >= a:
        tmp.appendleft(a)
    else:
        ind = bisect.bisect_right(tmp,a)
        tmp[ind-1] = a

print(len(tmp))


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = [inp() for _ in range(N)]

tmp = deque([])
first = True

for a in aa:
    if first:
        tmp.append(a)
        first = False
        continue

    if tmp[0] >= a:
        tmp.appendleft(a)
    else:
        ind = bisect.bisect_left(tmp,a)
        tmp[ind-1] = a

    

print(len(tmp))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
from bisect import bisect

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

dp = []
for a in A[::-1]:
    i = bisect(dp, a)
    if i < len(dp):
        dp[i] = a
    else:
        dp.append(a)
print(len(dp))

Failing test case input:
4
0
-1
0
0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
from sys import stdin
from bisect import bisect

N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))

dp = []
for a in A[::-1]:
    i = bisect(dp, a)
    if i < len(dp):
        dp[i] = a
    else:
        dp.append(a)
print(len(dp))

Problem: p02973
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import bisect
def get_LIS(seq):
    LIS = [seq[0]]
    for i in range(1,len(seq)):
        if seq[i] >= LIS[-1]:
            LIS.append(seq[i])
        else:
            LIS[bisect.bisect_left(LIS, seq[i])] = seq[i]

    print(len(LIS))


N = int(input())
A = [int(input()) for _ in range(N)]
A = A[::-1]
get_LIS(A)

Failing test case input:
5
0
0
0
5
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect
def get_LIS(seq):
    LIS = [seq[0]]
    for i in range(1,len(seq)):
        if seq[i] >= LIS[-1]:
            LIS.append(seq[i])
        else:
            LIS[bisect.bisect_right(LIS, seq[i])] = seq[i]

    print(len(LIS))


N = int(input())
A = [int(input()) for _ in range(N)]
A = A[::-1]
get_LIS(A)
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
INF = (10**5)+1
A = []
for i in range(N):
    a = int(input())
    A.append(a)

B = [A[-1]]
for i in range(N-2,-1,-1):
    a = A[i]
    if B[-1] > a:
        del B[-1]
        bisect.insort_left(B,a)
    else:
        bisect.insort_left(B,a)



print(len(B))



Failing test case input:
5
0
-1
1
4
0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)

B = [A[-1]]
del A[-1]
for a in reversed(A):
    if B[-1] <= a:
        B.append(a)
    else:
        B[bisect.bisect_right(B,a)] = a
    



print(len(B))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left

n = int( input() )
a = []
for i in range(n):
    a.append(int(input()))

min_stack = [a[-1]]

for i in range(2,n+1):
    if min_stack[-1] <= a[-i]:
        min_stack.append(a[-i])
    else:
        min_stack[bisect_left(min_stack, a[-i])] = a[-i]

print(len(min_stack))

Failing test case input:
5
0
0
0
7
0

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_left

n = int( input() )
a = []
for i in range(n):
    a.append(int(input()))

min_stack = [a[-1]]

for i in range(2,n+1):
    if min_stack[-1] <= a[-i]:
        min_stack.append(a[-i])
    else:
        tmp = min_stack[bisect_left(min_stack, a[-i])]
        if tmp == a[-i]:
            min_stack[bisect_left(min_stack, a[-i]+1)] = a[-i]
        else:
            min_stack[bisect_left(min_stack, a[-i])] = a[-i]

print(len(min_stack))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
A = [int(input()) for _ in range(N)]
Min = [A[-1]]
for i in range(N-2, -1, -1):
    temp = bisect.bisect_left(Min, A[i])
    if temp == len(Min):
        Min.append(A[i])
    elif Min[temp] != A[i]:
        Min[temp] = A[i]
    else:
        Min.append(A[i])
print(len(Min))

Failing test case input:
5
-1
0
1
2
1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):

import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
A = [int(input()) for _ in range(N)]
Min = [A[-1]]
for i in range(N - 2, -1, -1):
    temp = bisect.bisect_right(Min, A[i])
    if temp == len(Min):
        Min.append(A[i])
    elif Min[temp] != A[i]:
        Min[temp] = A[i]
    elif temp + 1 != len(Min):
        Min[temp + 1] = A[i]
    else:
        Min.append(A[i])
print(len(Min))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect


def main():
  n = int(input())
  a = [int(input()) for _ in range(n)]

  tail = []
  len_tail = 0
  for ai in a:
    idx = bisect.bisect_left(tail, -ai, lo=0, hi=len_tail) 
    if idx == len_tail:
      tail.append(-ai)
      len_tail += 1
    else:
      tail[idx] = - ai

  print(len_tail )


if __name__ == "__main__":
  main()

Failing test case input:
5
0
0
1
1
1

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):

import bisect


def main():
  n = int(input())
  a = [int(input()) for _ in range(n)]

  tail = []
  len_tail = 0
  for ai in a:
    idx = bisect.bisect_right(tail, -ai, lo=0, hi=len_tail) 
    if idx == len_tail:
      tail.append(-ai)
      len_tail += 1
    else:
      tail[idx] = - ai

  print(len_tail )


if __name__ == "__main__":
  main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(input()) for _ in range(n)]

import bisect
min_list = [-1]
for i in reversed(range(n)):
    if a[i] >= min_list[-1]:
        min_list.append(a[i])
    else:
        insert_index = bisect.bisect_left(min_list, a[i])
        min_list[insert_index] = a[i]
        min_list.sort()


print(len(min_list) - 1)


Failing test case input:
5
0
0
0
2
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for _ in range(n)]

import bisect
min_list = [-1]
for i in reversed(range(n)):
    if a[i] >= min_list[-1]:
        min_list.append(a[i])
    else:
        insert_index = bisect.bisect_right(min_list, a[i])
        min_list[insert_index] = a[i]
    


print(len(min_list) - 1)

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_right

n = int(input())
a = [int(input()) for _ in range(n)]

b = []

ans = 1
b.append(a[n-1])

for i in range(n-2, -1, -1):
    if a[i] >= b[-1]:
        b.append(a[i])
    else:
        x = bisect_right(b,a[i])
        b[x] = a[i]
        x -= 1
        while x >= 0:
            if b[x] > b[x+1]:
                b[x],b[x+1] = b[x+1],b[x]
                x -= 1
            else:
                break
    print(b)

print(len(b))



Failing test case input:
5
0
0
1
1
2

Expected output:
2


Actual output:
[1]
[1, 1]
[0, 1]
[0, 0]
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right

n = int(input())
a = [int(input()) for _ in range(n)]

b = []

ans = 1
b.append(a[n-1])

for i in range(n-2, -1, -1):
    if a[i] >= b[-1]:
        b.append(a[i])
    else:
        x = bisect_right(b,a[i])
        b[x] = a[i]
        x -= 1
        while x >= 0:
            if b[x] > b[x+1]:
                b[x],b[x+1] = b[x+1],b[x]
                x -= 1
            else:
                break
    

print(len(b))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

def LIS(A):
    
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_left(B, A[i+1])
            B[index] = A[i+1]
    return B

def LDS(A):
    
    A = A[::-1]
    B = [A[0]]
    for i in range(N-1):
        print(B)
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_right(B, A[i+1])
            B[index] = A[i+1]
    print(B)
    return B[::-1]


print(len(LDS(A)))

Failing test case input:
5
12
1
4
9
3

Expected output:
3


Actual output:
[3]
[3, 9]
[3, 4]
[1, 4]
[1, 4, 12]
3


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

def LIS(A):
    
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_left(B, A[i+1])
            B[index] = A[i+1]
    return B

def LDS(A):
    
    A = A[::-1]
    B = [A[0]]
    for i in range(N-1):
        if A[i+1] >= B[-1]:
            B.append(A[i+1])
        else:
            index = bisect.bisect_right(B, A[i+1])
            B[index] = A[i+1]
    return B[::-1]


print(len(LDS(A)))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect as bs
import collections

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = collections.deque()
min_ = 10000000000

for a in alist:
    if a <= min_:
        col.appendleft(a)
        min_ = a
    else:
        index = bs.bisect_left(col, a) - 1
        col[index] = a

print(len(col))


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect as bs
import collections

n = int(input())
alist = [0]*n
for i in range(n):
    alist[i] = int(input())

col = collections.deque()
min_ = 10000000000

for a in alist:
    if a <= min_:
        col.appendleft(a)
    else:
        index = bs.bisect_left(col, a) - 1
        col[index] = a
    min_ = col[0]

print(len(col))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


from bisect import bisect_left

N = int(input())

A = [int(input()) for _ in range(N)]

LIS = [A[0]]
cnt = 0

for a in A:
    if a > LIS[-1]:
        LIS.append(a)
    else:
        ind = bisect_left(LIS, a)
        LIS[ind] = a
        if ind == 0:
            cnt += 1

print(cnt)

Failing test case input:
5
10
-1
1
2
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):


from bisect import bisect_left
from collections import *

N = int(input())

A = [int(input()) for _ in range(N)]

LIS = deque([A[0]])
cnt = 0

for a in A[1:]:
    if a <= LIS[0]:
        LIS.appendleft(a)
    else:
        ind = bisect_left(LIS, a) -1
        LIS[ind] = a

print(len(LIS))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import bisect
import collections


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    la = [int(input()) for _ in range(n)]
    result = collections.deque()
    for a in la:
        idx = bisect.bisect_left(result, a)
        if idx == 0:
            result.appendleft(a)
        else:
            result[idx - 1] = a
    print(len(result))
    print(result)


main()


Failing test case input:
5
0
-1
1
4
0

Expected output:
2


Actual output:
2
deque([0, 4])


Fixed submission (verdict: Accepted):
import sys
import bisect
import collections


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    la = [int(input()) for _ in range(n)]
    result = collections.deque()
    for a in la:
        idx = bisect.bisect_left(result, a)
        if idx == 0:
            result.appendleft(a)
        else:
            result[idx - 1] = a
    print(len(result))


main()

Problem: p02973
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


import sys
input=sys.stdin.readline


def bisect(ite,x):
    st=-1
    en=len(ite)
    while(en-st>1):
        mid=(st+en)
        if ite[mid]>x:
            st=mid
        else:
            en=mid
    return en

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    
    lis=[A[0]]
    for i in range(1,N):
        if lis[-1]>=A[i]:
            lis+=[A[i]]
        else:
            lis[bisect(lis,A[i])]=A[i]
            
    print(len(lis))
    
if __name__=="__main__":
    main()


Failing test case input:
5
0
-1
0
3
0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):


import sys
input=sys.stdin.readline

def bisectR(ite,x):
    st=-1
    en=len(ite)
    while(en-st>1):
        mid=(en+st)
        if ite[mid]<x:
            en=mid
        else:
            st=mid
    return en

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    
    lbds=[A[0]]
    for i in range(1,N):
        if lbds[-1]>=A[i]:
            lbds+=[A[i]]
        else:
            x=bisectR(lbds,A[i])
            lbds[x]=A[i]
    print(len(lbds))
    
if __name__=="__main__":
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

ans = [A[0]]
l = 1
A.reverse()

for i in range(1, N):
    n = bisect.bisect_left(ans, A[i])
    if A[i] >= ans[-1]:
        ans.append(A[i])
    else:
        ans[n] = A[i]

print(len(ans))


Failing test case input:
5
10
-1
6
13
5

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

A.reverse()
ans = [A[0]]

for i in range(1, N):
    n = bisect.bisect_right(ans, A[i])
    if A[i] >= ans[-1]:
        ans.append(A[i])
    else:
        ans[n] = A[i]

print(len(ans))
Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect

N = int(input())
ans = 0
X = [int(input())for _ in range(N)]
A = []
for a in X[::-1]:
    if len(A) == 0:
        A.append(a)
    elif A[-1] <= a:
        A.append(a)
    else:
        i = bisect.bisect_left(A, a)
        A[i] = a

print(len(A))



Failing test case input:
5
1
0
0
5
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
ans = 0
X = [int(input())for _ in range(N)]
A = []
for a in X[::-1]:
    if len(A) == 0:
        A.append(a)
    elif A[-1] <= a:
        A.append(a)
    else:
        i = bisect.bisect_right(A, a)
        A[i] = a

print(len(A))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
N = int(N)
S = [int(input()) for _ in range(N)]
result = 0

for i in range(N):
    if S[i] >= 0:
        result += 1
        hoge = S[i]
        for j in range(i+1,N):
            if S[j] >= hoge:
                hoge = S[j]
                S[j] = -1 
print(result)

Failing test case input:
4
-1
0
0
0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
import bisect

N = input()
N = int(N)
S = [-int(input()) for _ in range(N)]
result = []

for i in range(N):
    hoge = bisect.bisect(result,S[i])
    if hoge == len(result):
        result.append(S[i])
    else:
        result[hoge] = S[i]
print(len(result))

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left

N = int(input())
Alist = [int(input()) for i in range(N)]

num_col = 1
L = [-1*Alist[0]] 
for ai in Alist[1:]:
    ai = -1*ai
    if ai >= L[-1]:
        L.append(ai)
        num_col += 1
    else:
        L[bisect_left(L, ai)] = ai
print(num_col)

Failing test case input:
5
1
0
1
1
0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from bisect import bisect_right
N = int(input())
Alist = [int(input()) for i in range(N)]

num_col = 1
L = [-1*Alist[0]] 
for ai in Alist[1:]:
    
    ai =-1*ai
    if ai >= L[-1]:
        L.append(ai)
        num_col += 1
    else:
        L[bisect_right(L, ai)] = ai
print(num_col)

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
H = []
min_lst = 10 ** 9
for _ in range(N):
    a = int(input())
    if min_lst >= a:
        min_lst = a
        H.append(-a)
    else:
        ind = bisect.bisect_left(H, -a)
        H[ind] = -a
        if ind == len(H) - 1:
            min_lst = a
print(len(H))


Failing test case input:
5
0
0
-1
0
0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
H = []
for _ in range(N):
    a = int(input())
    ind = bisect.bisect_right(H, -a)
    if ind == len(H):
        H.append(-a)
    else:
        H[ind] = -a
print(len(H))
Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.append(a)
        else:
            d[t-1] = a
    print(len(d))
    print(d)
if __name__ == '__main__':
    main()


Failing test case input:
5
12
0
4
9
3

Expected output:
3


Actual output:
3
deque([3, 9, 12])


Fixed submission (verdict: Accepted):


from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))
if __name__ == '__main__':
    main()

Problem: p02973
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = input()
N = int(N)
S = [int(input()) for _ in range(N)]
result = []

for i in range(N):
    hoge = bisect.bisect_left(result,S[i])
    if hoge == 0:
        result = [S[i]] + result
    else:
        result[hoge - 1] = hoge
print(len(result))

Failing test case input:
5
-1
0
1
2
1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N = input()
N = int(N)
S = [-int(input()) for _ in range(N)]
result = []

for i in range(N):
    hoge = bisect.bisect(result,S[i])
    if hoge == len(result):
        result.append(S[i])
    else:
        result[hoge] = S[i]
print(len(result))

Problem: p02973
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from bisect import bisect_left as bl
N = int(input())
inf = 10 ** 9 + 1
lis = [inf] * (N + 1)
liscount = [0] * (N + 1)
for _ in range(N):
  a = int(input())
  ind = bl(lis, a)
  if a <= lis[ind]:
    lis[ind] = a
    liscount[ind] -= 1
print(-min(liscount))

Failing test case input:
5
3
-1
1
3
1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
from bisect import bisect_right as br
N = int(input())
inf = 10 ** 9 + 1
lis = [inf] * (N + 1)
res = 0
for _ in range(N):
  a = -int(input())
  ind = br(lis, a)
  if a <= lis[ind]:
    lis[ind] = a

for i in range(1, N + 1):
  if lis[i] == inf:
    break
  res = i
print(res + 1)