Problem:


Score : 500 points

Problem Statement

You are given a sequence with N integers: A = \{ A_1, A_2, \cdots, A_N \}.
For each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:

If A_i and A_j (i < j) are painted with the same color, A_i < A_j.

Find the minimum number of colors required to satisfy the condition.

Constraints

1 \leq N \leq 10^5

0 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print the minimum number of colors required to satisfy the condition.

Sample Input 1

5
2
1
4
5
3

Sample Output 1

2

We can satisfy the condition with two colors by, for example, painting 2 and 3 red and painting 1, 4, and 5 blue.

Sample Input 2

4
0
0
0
0

Sample Output 2

4

We have to paint all the integers with distinct colors.



Sample input:
5
2
1
4
5
3


Sample output:
2

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [None] * n
count = 1
#mins = []
lasts = []

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

#mins.append(a[0])

for i in range(1, n):
    if a[i] > a[i-1]:
        continue
    else:
#        lasts.append(a[i-1])
        for j in reversed(range(len(lasts))):
            if lasts[j] < a[i]:
                lasts[j] = a[i]
                break
        else:
            lasts.append(a[i])
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
min = 100000000000
num = 0

for i in range(N):
	A = int(input())
	if A <= min:
		min = A
		num += 1

print(num)

Submission status: Wrong Answer

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

import bisect
from collections import deque
D=deque([A[0]])

for a in A[1:]:
    if a<=D[0]:
        D.appendleft(a)
        
    x = bisect.bisect_right(D,a-1)
    D[x-1]=a

    #print(D)

print(len(D))

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=[-1]*(n+1)
num=1
ans[0]=arr[0]
m=arr[0]
for i in range(1,n):
  if arr[i]<=m:
    ans[num]=arr[i]
    num+=1
  else:
    for j in range(num):
      m=min(m,ans[j])
      if ans[j]<arr[i]:
        ans[j]=arr[i]
        break
print(num)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(input())]

for i in range(1, n):
  min_nums = min(nums)
  nn = int(input())
  
  # すでにあるリストのどの数よりも小さければ、リストに追加する
  if nn <= min_nums:
    nums.append(nn)
  
  # リストのある数よりも大きければ、その要素を上書きする
  else:
    # nnより小さく、差が大きいものを選ぶ
    nnn = [nn] * len(nums)
    nums_d = [x - y for (x, y) in zip(nnn, nums)]
    
    min_nums_d = min(i for i in nums_d if i > 0)
    min_nums_d_index = nums_d.index(min_nums_d)
    
    # 置き換える
    nums[min_nums_d_index] == nn
    
print(len(nums))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:

import bisect as bs

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

col = []
min_ = 1000000000

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

print(len(col))

Submission status: Wrong Answer

Solution code:
a=[int(input())for i in[0]*int(input())]
b=a[0]
k=0
d=1
for i in range(len(a)-1):
  if b>a[i]:d+=1;b=a[i];d=i
  elif a[i]in a[k:i]:d+=1
print(d)

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
a = [0] * n

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

color = [a[0]]
color_min = a[0]

for i in range(1, n):
    if color_min >= a[i]:
        bisect.insort_right(color, a[i])
        color_min = a[i]
    else:
        j = bisect.bisect_left(color, a[i])
        color[j-1] = a[i]

print(len(color))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
f = [0]*(n+1)
count = 0
for i in range(n):
  ai = int(input())
  a.append(ai)

ans = 0
while(count<n):
  for i in range(n):
    if(f[i]==0):
      f[i] = 1
      flag = 0
      ans = ans + 1
      count += 1
      for j in range(i+1,n):
        if(a[j] > a[i]):
          f[j] = 1
          count = count + 1
     
print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import *
N = int(input())
A = [int(input()) for i in range(N)]
lb, ub = 0, N
while lb + 1 < ub:
    mid = (lb+ub)//2
    cnt, ms, m, flag = 1, [-A[0]], A[0], 1
    for a in A[1:]:
        if a <= m:
            m = a
            cnt += 1
            if cnt > mid:
                flag = 0
                break
        else:
            heapreplace(ms, -a)
            m = min(m, a)
    if flag:
        ub = mid
    else:
        lb = mid
cnt, ms, m, flag = 1, [-A[0]], A[0], 1
for a in A[1:]:
    if a <= m:
        m = a
        cnt += 1
        if cnt > mid:
            flag = 0
            break
    else:
        heapreplace(ms, -a)
        m = min(m, a)
if flag:
    print(mid)
else:
    print(mid+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

m = 0
p = -1
M = 0
for _ in A:
    if _ >= p:
        m += 1
        if m > M:
            M = m
    else:
        m = 0
    p = _
print(M)

Submission status: Wrong Answer

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


mina = 10**9 + 1
# print(mina)
ans = 0
for i in range(N):
    if mina>=A[i]:
        ans +=1 
        mina = A[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import *
N = int(input())
A = [int(input()) for i in range(N)]
lb, ub = 0, N
while lb + 1 < ub:
    mid = (lb+ub)//2
    cnt, ms, m, flag = 1, [-A[0]], A[0], 1
    for a in A[1:]:
        if a <= m:
            m = a
            cnt += 1
            if cnt > mid:
                flag = 0
                break
        else:
            heapreplace(ms, -a)
            m = min(m, a)
    if flag:
        ub = mid
    else:
        lb = mid
print(ub)

Submission status: Wrong Answer

Solution code:
def reverse_bisect(a, x, lo=0, hi=None):
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x <= a[mid]: hi = mid
        else: lo = mid+1
    return lo

N = int(input())
color_list = []
color_len = 0
for i in range(N):
    a = int(input())
    index = reverse_bisect(color_list, a, 0, color_len)
    if(index == 0):
        color_list.append(a)
        color_len += 1
    else:
        color_list[color_len - index] = a
print(color_len)

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = [int(input()) for __ in range(N)]

    ans = len(A)
    for i in range(N):
        if sum(A) == 0:
            break

        if A[i] == 0:
            continue

        k = A[i]
        A[i] = 0
        for j in range(i+1, N):
            if k < A[j]:
                A[j] = 0
                ans -= 1
    print(ans)

resolve()

Submission status: Wrong Answer

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

import bisect
from collections import deque
D=deque([A[0]])

for a in A[1:]:
    if a<=D[0]:
        D.appendleft(a)
        
    x = bisect.bisect_right(D,a)
    D[x-1]=a

    #print(D)

print(len(D))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

input=sys.stdin.readline

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

c=Counter(a)

k,v=zip(*c.most_common())
print(max(2,v[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

ans = [a[0]]
count = 0
for i in range(1,n):
    if a[i] > a[i-1]:
        ans[count] = a[i]
    else:
        mi = min(ans)
        if mi < a[i]:
            idx = ans.index(mi)
            ans[idx] = a[i]
            count = idx
        else:
            ans.append(a[i])
            count += 1
print(len(ans))

Submission status: Wrong Answer

Solution code:
import bisect

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

color = [float("inf")]
min_color = color[0]
for i in a:
    if i <= min_color:
        color = [i] + color
        min_color = i
    else:
        insert = bisect.bisect_left(color, i - 1)
        bisect.insort(color, i)
        del color[insert]
        if insert == 0:
            min_color = color[0]
print(len(color) - 1)

Submission status: Wrong Answer

Solution code:
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()

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
S = [int(input()) for _ in range(N)]
result = 0
ababa = 0

while ababa < N:
    result += 1
    ababa += 1
    hoge = S.pop(0)
    onon = 0
    for j in range(len(S)):
        if S[onon] > hoge:
            S.pop(onon)
            ababa += 1
        else:
            onon + 1
print(result)

Submission status: Wrong Answer

Solution code:
#coding : utf-8

import os
import sys

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))

#print(N)
#print(A)

min_value = A[0]
colors = 1

for i in range(1, N):
	if A[i] <= min_value:
		min_value = A[i]
		colors += 1

print(colors)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=int(input())
ans=1
for i in range(n-1):
    a=int(input())
    if x>=a:
        x=a
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans=0
tmp_ans=0
for i in range(1,N):
    if(max(A[:i]) >= A[i]):
        ans +=1

if(A[0] >= A[1]):
    ans +=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
A_sort = sorted(A, reverse=True)

cnt = 0
for a in A:
    while len(A_sort) > 1:
        if a not in A_sort:
            break
        else:
            del A_sort[:A_sort.index(a) + 1]
            cnt += 1
            break
else:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
print(n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

# a[i] >= a[i+1]の数を数える。条件が成立したa[i]の値を保持する
count = 0
local_max = an[0]
for i in range(N-1):
    if an[i] >= an[i+1]:
        count += 1
        local_max = an[i]
    else:
        # local_maxより小さければlocal_maxに当てた色と同じ色にすればよい
        if local_max <= an[i]:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:

def main():
    n = int(input())
    a = []

    m = float('inf')
    cnt = 0

    for i in range(n):
        tmp = int(input())
        if tmp <= m:
            m = tmp
            cnt+= 1
            
    print(cnt)


main()

Submission status: Wrong Answer

Solution code:
import heapq

def solve():
  N = int(input())
  A = [int(input()) for i in range(N)]
  C = []
  heapq.heapify(C)
  heapq.heappush(C, A[-1] * -1)
  for i in range(N - 2, -1, -1):
    maximum = heapq.heappop(C) * -1
    if A[i] >= maximum: heapq.heappush(C, maximum * -1)
    heapq.heappush(C, A[i] * -1)

  return len(C)

print(solve())

Submission status: Wrong Answer

Solution code:
N = int(input())
A = {}
for i in range(N):
        n = input()
        if n in A:
                A[n] += 1
        else:
                A[n] = 1
print(max(max(A.values()),2))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(input()) for i in range(n)]
#print(n,l)

res = 0
m = 0
for i in range(n):
    x = l[n-1-i]
    if m <= x:
        m = x
        res += 1
        #print(n-1-i,m,res)
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))
count = 0
while True:
  count += 1
  stand = a.pop(0)
  i = 0
  while True:
    try:
      if a[i] > stand:
        del a[i]
      else:
        i += 1
    except:
      break
  if a == []:
    break
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

x = [a[0]]
for i in a[1:]:
    if i <= min(x):
        x.append(i)

print(len(x))

Submission status: Wrong Answer

Solution code:
a=[int(input())for i in[0]*int(input())]
b=a[0]
k=0
d=1
for i in range(len(a)-1):
  if b>a[i]:d+=1;b=a[i]
  elif a[i]in a[k:i]:d+=1
print(d)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] * N
C = [-1]
for i in range(N):
  A[i] = int(input())
  s = 0
  t = len(C) - 1
  if C[0] < A[i]:
    C[0] = A[i]
    continue
  if C[-1] >= A[i]:
    C.append(A[i])
    continue
  while t - s > 1:
    m = (t + s) // 2
    if C[m] > A[i]:
      t = m
    else:
      s = m
  C[t] = A[i]
print(len(C))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []

for i in range(N):
    A.append(int(input()))

ans = 1
maxa = A[0]
for a in A[1:]:
        if a <= maxa:
            ans += 1
            maxa = a

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(input())]

for i in range(n-1):
    a=int(input())
    f=True
    for i in range(len(l)):
        if l[i]<a:
            l[i]=a
            f=False
            break
    if f:
        l.append(a)
    l.sort()
print(len(l))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

que = []
num = 0
for i in range(N):
    if not que:
        num += 1
        que.append(A[i])
    else:
        k = bisect_right(que, A[i])
        if k == 0:
            num += 1
            que.insert(0, A[i])
        elif k == len(que) and que[-1] == A[i]:
            num += 1
            que.append(A[i])
        elif k == len(que):
            que.pop(-1)
            que.append(A[i])
        else:
            que.pop(k - 1)
            que.insert(k - 1, A[i])

print(num)

Submission status: Wrong Answer

Solution code:
n = int(input())

a0 = int(input())
aifoward = a0

ans = 1

for i in range(1, n):
    ai = int(input())
    if ai <= aifoward:
        ans += 1
        aifoward = ai

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    a = []
    
    col = 1

    for _ in range(n):
        a.append(int(input()))
    
    if n == 1:
        print(col)
        exit()

    b = [a[0]]

    for i in range(1,n):
        x = bisect_left(sorted(b),a[i])
        if x == 0:
            col += 1
            b.append(a[i])
        
        else:
            a[x] = a[i]
            
    print(col)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = []
num = 0

for i in range(N):
	A = int(input())
	for j in range(len(S)):
		index = j
		if A > S[j]:break
	else:
		S.append(A)
		num += 1

print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = []
for i in range(N):
  A = int(input())
  As.append(A)
num = 1
s = []
c = As[0]
for i in range(1,N):
  A = As[i]
  if c < A:
    c = A
  else:
    if len(s) > 0 and s[len(s)-1] < A:
      s.pop()
      c = A
    else:
      num += 1
      s.append(c)
      c = A
print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
color=np.array([-1])
for i in range(n):
    a=int(input())
    if a<=color.min():
        color = np.append(color,a)
    else:
        close_a_index = np.argmax(color[color<a])
        color[close_a_index] = a
print(color.size)

Submission status: Wrong Answer

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <20/Jul/2019 06:18:39 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = [0] * n
    for i in range(n):
        arr[i] = int(input())
    ans = 1
    for i in range(1, n):
        if arr[i] <= arr[i - 1]:
            ans += 1
    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
cnt = 1
a = int(input())
nums = [a]
nums.sort()
for i in range(n - 1):
    a = int(input())
    if a <= nums[0]:
        cnt += 1
        nums.insert(0,a)
    else:
        for j in range(len(nums)):
            if nums[0] <= a:
                continue
            else:
                nums[j - 1] = nums[j]
                nums[j] = a
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
c=1
for i in range(N):
    A.append(int(input()))
for j in range(0,N-1):
    if A[j]>=A[j+1]:
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]

S = []

cnt = 0
for i in range(N):
    j = bisect.bisect_left(S, A[i])
    if j <= 0:
        cnt += 1
        S.insert(i, A[0])
    S[j-1] = A[i]

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())

a0 = int(input())
aifoward = a0

ans = 1

for i in range(1, n):
    ai = int(input())
    if ai <= aifoward:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = []
for i in range(N):
  A = int(input())
  As.append(A)
num = 1
s = []
c = As[0]
for i in range(1,N):
  A = As[i]
  if c > A:
    c = A
  else:
    if len(s) > 0 and s[len(s)-1] < A:
      s.pop()
      c = A
    else:
      num += 1
      s.append(c)
      c = A
print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
A_sort = sorted(A, reverse=True)

cnt = 0
for a in A:
    while len(A_sort) > 0:
        if a not in A_sort:
            break
        else:
            del A_sort[:A_sort.index(a)]
            cnt += 1
        break
    continue
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
mina = int(input())
ans = 1
for i in range(N-1):
    a = int(input())
    if a <= mina:
        ans += 1
        mina = a

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(int(input()) for _ in range(n))

counter = 1
minimum = a[0]

for i in range(1, n):
    if a[i] <= minimum:
        counter += 1
        minimum = a[i]

print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list([int(input()) for i in range(N)])
minnums = 0
numcount = 0
nextcounter = 0
check = False
for i in range(len(nums)-1):
    if nums[i]>=nums[i+1]:
        numcount+=1
        if check==False:
            nextcounter+=1
        check=True
    else:
        check=False
print(numcount+1-(nextcounter-1))

Submission status: Wrong Answer

Solution code:
import heapq

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

ans = []
heapq.heappush(ans, A[0])
for i in range(1, N):
    if A[i] > ans[0]:
        ans[0] = A[i]
    else:
        heapq.heappush(ans, A[i])

print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
b = [a[0]]
count = 1

for i in range(1,n):
    for ii in range(len(b)):
        if a[i] > b[ii]:
            a[i] = b[ii]
        elif ii == len(b)-1:
            b.append(a[i])
            count += 1
            break

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [None] * n
count = 1

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

minV = a[0]

for i in range(1, n):
    if a[i] > a[i-1]:
        continue
    else:
        if a[i] <= minV:
            count += 1
            minV = a[i]

print(count)

Submission status: Wrong Answer

Solution code:
a=[int(input())for i in[0]*int(input())]
b=a[0]
d=1
for i in a[1:]:
  if b>i:d+=1;b=i
for i in set(a):
  d+=a.count(i)-1
print(d)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()

mx = -1
i = 0
ans = 0
while i < N:
  if A[i] >= mx:
    ans += 1
    mx = A[i]
  i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [None] * n
count = 1

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

minV = a[0]

for i in range(1, n):
    if a[i] > a[i-1]:
        continue
    else:
        if a[i] <= minV:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
a=[int(input())for i in[0]*int(input())]
b=a[0]
d=1
for i in a[1:]:
  if b>=i:d+=1;b=i
print(d)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

ans = [a[0]]
count = 0
for i in range(1,n):
    if a[i] > a[i-1]:
        ans[count] = a[i]
    else:
        flag = 0
        for j in range(len(ans)):
            if ans[j] < a[i]:
                ans[j] = a[i]
                flag = 1
                break
        if flag == 0:
            ans.append(a[i])
            count += 1
print(len(ans))

Submission status: Wrong Answer

Solution code:
# 2019/07/20
# AtCoder Beginner Contest 134 - E

# Input
n = int(input())

# Input and Search Max and 2nd Max
a = list()
minlist = list()
for i in range(n):
    wka = int(input())
    adflg = True
    for j in range(len(minlist)):
        if minlist[j] < wka:
            adflg = False
            break

    if adflg == True:
        minlist.append(wka)

    a.append(wka)

# Output
print(len(minlist))

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[int(input()) for _ in range(n)]
flag=False
for i in range(n-1):
  if arr[i]==arr[i+1]:
    continue
  else:
    flag=True
    break
if flag==False:
  print(n)
else:
  ans=0
  for i in range(n-1):
    if arr[i]>=arr[i+1]:
      ans+=1
  print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
A.reverse()
ans = 0
m = -1

for a in A:
    if a >= m:
        m = a
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
a=[int(input())for i in[0]*int(input())]
b=a[0]
c=a[0]
d=1
for i in a[1:]:
  if b>=i:d+=1
  if c>i:c=i
print(d)

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    pass

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

    ans = 0
    prev = 0
    for i in range(N):
        if prev >= A[i]:
            ans += 1
        prev = A[i]
    
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]

ans = [a[0]]
count = 0
for i in range(1,n):
    if a[i] > a[i-1]:
        ans[count] = a[i]
    else:
        flag = 0
        for j in range(len(ans)):
            if ans[j] < a[i]:
                ans[j] = a[i]
                flag = 1
                break
        if flag == 0:
            ans.append(a[i])
print(len(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())

A=[int(input()) for _ in range(N)]
B=[A[0]]
for i in range(1,N):
    if A[i]>max(B):
        B[0]=A[i]
    elif A[i]<=min(B):
        B.append(A[i])
    else:
        for j in range(len(B)-1):
            if A[i]<=B[j]:
                continue
            else:
                B[j]=A[i]
                break

print(len(B))

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

seq = deque()
for a in A:
    i = bisect.bisect_left(seq, a)
    if i == 0:
        seq.appendleft(a)
    else:
        seq[i - 1] = a
        while i < len(seq) and seq[i - 1] < seq[i]:
            seq[i], seq[i - 1] = seq[i - 1], seq[i]
            i += 1
print(len(seq))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
cnt = 1
m = a[0]
for i in range(1, n):
    if a[i - 1] >= a[i]:
        if a[i] <= m:
            cnt += 1
            m = a[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
m = -1

for a in A:
    if a >= m:
        m = a
        ans += 1
if m > A[0]:
    ans -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
w=[]
for i in range(0,n):
    o=int(input())
    l.append(o)
A=1;
w.append(int(l[0]))
for i in range(1,len(l)):
    w.sort(key=int)
    if int(l[i]) > w[0]:
        continue;
    else:
        A+=1;
        w.append(l[i])
print(A)

Submission status: Wrong Answer

Solution code:
a=[int(input())for i in[0]*int(input())]
b=10**10
print(1+len([0for i in range(len(a)-1)if i<=min(a[:i+1]+[b])]))

Submission status: Wrong Answer

Solution code:
N = int(input())
num = 0
now = 10000000001
for i in range(N):
    t = int(input())
    if t <= now:
        num += 1
        now = t
print(num)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N = int(input())

A = np.empty(N)
for i in range(N):
   A[i] = int(input())

color = 1
p=0
for i in range(1,N):
   if(A[i]<=A[i-1]):
      if(A[i]>A[p]):
         p=i
         continue
      color += 1
      p = i-1
   else:
      continue

print(color)

Submission status: Wrong Answer

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

color = [float("inf")]
min_color = min(color)
for i in a:
    if i <= min_color:
        color.append(i)
        min_color = i
print(len(color) - 1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=int(input())
ans=1
for i in range(n-1):
  b=int(input())
  if s>=b:
    ans+=1
    s=b
  else:
    s=b
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []

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

sln = []

prev = a[0]

for i in range(1,n):
    prev = a[i - 1]
    cur = a[i]
    if cur <= prev:
        if len(sln) == 0:
            sln.append(prev)
            sln.append(cur)
        else:
            if cur <= sln[0]:
                sln.append(cur)
            else:
                for j in range(0, len(sln)):
                    if sln[j] < cur:
                        sln[j] = cur
                        sln.sort(reverse=True)
                        break

print(len(sln))

Submission status: Wrong Answer

Solution code:
n = int(input())
i = 0
A = []
while i < n:
	A.append(int(input()))
	i += 1
	
color = 1
change = []
for i in range(n-1):
	if A[i] >= A[i+1]:
		change.append(A[i])
		color += 1
		
for j in range(len(change)-1):
	if change[j] < change[j+1]:
		color-= 1
		
print(color)

Submission status: Wrong Answer

Solution code:
N = int(input())
mina = 10*10
ans = 0
for i in range(N):
    a = int(input())
    if a <= mina:
        ans += 1
        mina = a

print(ans)