Problem:


Score : 300 points

Problem Statement

Given is a permutation P_1, \ldots, P_N of 1, \ldots, N.
Find the number of integers i (1 \leq i \leq N) that satisfy the following condition:  

For any integer j (1 \leq j \leq i), P_i \leq P_j.

Constraints

1 \leq N \leq 2 \times 10^5

P_1, \ldots, P_N is a permutation of 1, \ldots, N.  

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
P_1 ... P_N

Output

Print the number of integers i that satisfy the condition.

Sample Input 1

5
4 2 5 1 3

Sample Output 1

3

i=1, 2, and 4 satisfy the condition, but i=3 does not - for example, P_i > P_j holds for j = 1.

Similarly, i=5 does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.

Sample Input 2

4
4 3 2 1

Sample Output 2

4

All integers i (1 \leq i \leq N) satisfy the condition.

Sample Input 3

6
1 2 3 4 5 6

Sample Output 3

1

Only i=1 satisfies the condition.

Sample Input 4

8
5 7 4 2 6 8 1 3

Sample Output 4

4

Sample Input 5

1
1

Sample Output 5

1



Sample input:
5
4 2 5 1 3


Sample output:
3

Submission status: Accepted

Solution code:
# C - Low Elements
def main():
    N, *P = map(int, open(0).read().split())
    ans, cur_min = 0, P[0]
    for i in P:
        if i <= cur_min:
            ans += 1
            cur_min = i
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# C - Low Elements
def main():
    N, *P = map(int, open(0).read().split())
    ans, cur_min = 0, P[0]
    for i in P:
        if i <= cur_min:
            ans += 1
        cur_min = min(cur_min, i)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))
"""
1以上前提
配列番号(j<=i)であるとき
配列要素がi<=jとなる個数

1~iまでで中身が降順であるかどうか
すなわち、探索範囲での先頭が最小かどうかを調べればいい。

問題文3行目より、必ずj,iは1番目を探索しなければならない。
"""
res = 0
before = 10**9 
for i in range(N):
    if P[i] < before:
        before = P[i]
        res += 1
else:
    print(res)

Submission status: Accepted

Solution code:
n=int(input())
P=list(map(int,input().split()))

M=[0]*n
M[0]=P[0]

for i in range(n-1):
  M[i+1]=min(M[i],P[i+1])

ans=0
for i in range(n):
  ans+=P[i]==M[i]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
cnt = 0
m = N + 1
for i in range(N):
    if A[i]<m :
        cnt += 1
        m = A[i]
print(cnt)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
P = np.array(read().split(),np.int32)

Q = np.minimum.accumulate(P)

answer = np.count_nonzero(P <= Q)

print(answer)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int, input().split()))
cnt=1
nmin=l[0]
for i in range(1,n):
	if nmin>=l[i]:
		cnt+=1
		nmin=l[i]
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

nums = input().split()
nums = [int(x) for x in nums]

min = None
count = 0

for idx, num in enumerate(nums):
    if idx == 0:
        min = num
        count += 1
        continue

    if min >= num:
        count += 1
        min = num

print(count)

Submission status: Accepted

Solution code:
def pred(i, lst, offset):
  for cmpd in lst[offset:i+1]:
    if lst[i] > cmpd:
      return False
  return True

n = int(input())
p = [int(m) for m in input().split(' ')]

sum = 0
minimum = n + 1
for i in range(n):
  if p[i] < minimum:
    sum += 1
    minimum = p[i]

#sum = 0
#offset = 0
#for i in range(n):
#  if pred(i, p, offset):
#    sum += 1
#    offset = i

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

P = [int(x) for x in input().split()]

cnt = 1
m = P[0]
for i in P[1:]:
  if i < m:
    m = i
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
ans=1
min_num=p[0]
for i in range(1,n):
    if p[i]<=min_num:
        ans+=1
        min_num=p[i]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=[int(i) for i in input().split()]

mini=[p[0]]*n
for i in range(n-1):
  mini[i+1]=min(mini[i],p[i+1])
ans=1
for i in range(1,n):
  if p[i]<=mini[i-1]:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
mi = p[0]
ans = 0
for i in p:
    if i > mi:
        pass
    else:
        ans += 1
        mi = i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
m=p[0]
count=1
for i in range(1,n):
  if m>p[i]:
    count+=1
    m=p[i]
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
now = 10 ** 18
for i in a:
  if i < now:
    ans += 1
    now = i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
n_list = list(map(int, input().split()))

minNum = N

ans = 0
for n in range(N):
  minNum = min(n_list[n], minNum)  
  if(minNum == n_list[n]):
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
mn = a[0]
ans = 0
for i in range(n):
    if a[i] <= mn:
        ans += 1
    mn = min(mn, a[i])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = [int(x) for x in input().split()]
ans = 0
mn = n
for i in p:
  if mn > i:
    mn = i
  if mn >= i:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
ans=0
a=p[0]
for i in range(n):
  a=min(a,p[i])
  if p[i] <= a:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
#abc152c

n=int(raw_input())
p=map(int,raw_input().split())
cnt=0
x=float('inf')
for i in p:
 if i<=x:
  x=i
  cnt+=1
print cnt

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()
a = l()
ma = Max
co = 0
for i in range(n):
    if a[i] < ma:
        ma = a[i]
        co += 1
print(co)

Submission status: Accepted

Solution code:
a = int(raw_input())
P = map(int,raw_input().split())
P_min = P[0]
ans = 1
for i in range(1,a):
  if P_min >= P[i]:
    ans += 1
    P_min = P[i]
print ans

Submission status: Accepted

Solution code:
n=int(input())
s=list(map(int,input().split()))
 
ans=0
smin=s[0]
for i in range(n):
    if s[i]<=smin:
        ans+=1
        smin=s[i]
    
print(ans)

Submission status: Accepted

Solution code:
def solve(string):
    n, *p = map(int, string.split())
    ans = 0
    m = n + 1
    for _p in p:
        if _p < m:
            ans += 1
            m = _p
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
P=list(map(int,input().split()))
count = 0
saisyouti = P[0]
for i in range(N):
    if P[i]<=saisyouti:
        count += 1
        saisyouti=P[i]
print(count)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
ans = 1
minv = P[0]
for i in range(1, len(P)):
    if P[i] <= minv:
        ans += 1
        minv = P[i]
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
p = np.array(list(map(int, input().split())))

mi = np.minimum.accumulate(p)
print(np.count_nonzero(p<=mi))

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))

flg_min = p[0]
ans = 1
for i in range(1, n):
    temp = p[i]
    if flg_min > temp:
        ans += 1
        flg_min = temp
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
P = list(map(int, input().split()))

mini = float('INF')

count = 0
for num in P:
    if mini >= num:
        count += 1
        mini = num
    else:
        continue

print(count)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

cnt = 0
mi = P[0]
for i in range(N):
	if P[i] <= mi:
		mi = P[i]
		cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
 
A = 0
C = P[0]
for i in range(N):
  if P[i] <= C:
    C = P[i]
    A += 1
print(A)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
mi = 10 ** 6
cnt = 0
for i in p:
    if mi > i:
        cnt += 1
        mi = i

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))

ans = 0
tmp_min = n + 1
for i in range(n):
    if p[i] < tmp_min:
        ans += 1
    tmp_min = min(tmp_min, p[i])

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
Plist = list(map(int, input().split()))
ans = 0
M = Plist[0]
for i in range(N):
    M = min(M, Plist[i])
    if Plist[i] == M:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
l=[]
for i in range(n):
  l.append(i+1)
if p[0]==1:
  print(1)
else:
  ans=0
  k=float('inf')
  for i in range(n):
    if p[i]<=k:
        k=p[i]
        ans+=1
  print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
cnt = 1
min = l[0]
for i in range(1, len(l)):
    if min > l[i]:
        min = l[i]
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
count=0
low=A[0]
for i in range(len(A)):
    if low>=A[i]:
        count+=1
    low=min(low,A[i])
print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
t = n+1
cnt = 0
for x in l:
  if x < t:
    t = x
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
t=10**10
c=0
for a in A:
    if(a<=t):
        c+=1
        t=a
print(c)

Submission status: Accepted

Solution code:
n = int(input())
P = list(map(int, input().split()))

com = P[0]
cnt = 1

for i in range(1, n):
    if P[i] <= com:
        com = P[i]
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

ans = 0
bottom = P[0]
for i in range(N):
    if P[i] <= bottom:
        ans += 1
    bottom = min(P[i], bottom)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
l = np.array([int(i) for i in input().split()])

q = np.minimum.accumulate(l)
ans = np.count_nonzero(l <= q)

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
tmin = p[0]
res = 0
for sp in p:
    if tmin>=sp:
        res += 1
        tmin = sp
print(res)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split(" ")))
m = [P[0]]
for i in range(1, N):
  if P[i] < m[-1]:
    m.append(P[i])
print(len(m))

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split(" ")))
m = P[0]
c = 1
for i in range(1, N):
  if P[i] < m:
    c += 1
    m = P[i]
print(c)

Submission status: Accepted

Solution code:
N = int(input())
Ps = list(map(int, input().split()))
count = 0
min = Ps[0]+1

for i in range(N):
    if (Ps[i] < min):
        min = Ps[i]
        count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
MIN = n+1
count = 0
for i in range(n):
    if MIN > p[i]:
        count += 1
    MIN = min(MIN,p[i])
print(count)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
curMin = float("inf")
ans = 0
for x in P:
    curMin = min(curMin, x)
    if curMin == x:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for _ in p:  #p[i]よりも小さいものが出てきたらだめ
    if _ <= n:
        cnt += 1
        n = _
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
ans = 0
nmin = P[0]
for x in P:
    if x <= nmin:
        ans += 1
        nmin =x
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

ans = 0
min = 10000000

for p in P:
  if min > p:
    ans += 1
    min = p

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
ans = 0
min_num = 10**6
 
for i in range(N):
    min_num = min(min_num, P[i])
    if min_num >= P[i]:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
#C
N = int(input())
P = list(map(int, input().split()))
ans = 0
min_num = 10**6

for i in range(N):
    min_num = min(min_num, P[i])
    if min_num >= P[i]:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
lis = list(map(int, input().split()))

counter=0
minimum = 10000000
for i in range(N):
    minimum = min([minimum,lis[i]])
    counter += int(lis[i] <= minimum)
print(counter)

Submission status: Accepted

Solution code:
N = int(input())

nums = input().split()
nums = [int(x) for x in nums]

min = None
count = 0

for idx, num in enumerate(nums):
    if idx == 0:
        min = num
        count += 1
        continue
    
    if min >= num:
        count += 1
        min = num
    
print(count)

Submission status: Accepted

Solution code:
N = int(input())
Data = list(map(int,input().split()))
cmin = (10**5)*2 + 1
ans = 0
for i in range(N):
    if Data[i] <= cmin:
        ans += 1
        cmin = Data[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))

m = p[0]
ans = 1
for pi in p[1:]:
    if pi <= m:
        ans += 1
        m = pi
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [_ for _ in map(int,input().split())]
res = 0
for x in L:
  if x <= N:
    res += 1
    N = x #最小上書き。次にresが増えるのは後々の要素で最小より小さいのが出てきたとき。
print(res)
#みんなもtabulationミスってREには気をつけようね

Submission status: Accepted

Solution code:
import numpy as np
import sys

count=0
N=int(sys.stdin.readline().rstrip())
P=[int(i) for i in sys.stdin.readline().split()]
minval=np.max(P)
for i in range(0,N):
  if minval>=P[i]:
    minval=P[i]
    count+=1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=a[0]
ans=1
for i,z in enumerate(a):
  if i==0:continue
  if z<=m:
    ans+=1
  m=min(m,z)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
P=list(map(int,input().split()))
mn=2*10**5+1
cnt=0

for item in P:
  if mn>item:
    cnt+=1
    mn=item
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

minLeft = [a[0]] + [None] * (n - 1)
for i in range(1, n):
    minLeft[i] = min(minLeft[i - 1], a[i])
ret = 1
for i in range(1, n):
    ret += a[i] < minLeft[i - 1]
print(ret)

Submission status: Accepted

Solution code:
[n] = map(int, input().split())
[*p_list] = map(int, input().split())

count = 0
p_min = 2 * 10 ** 5

for p in p_list:
  if p_min >= p:
    count += 1
    p_min = p

print(count)

Submission status: Accepted

Solution code:
import math

n = int(input())
ps = map(int, input().split())

minNum = 300000
ans = 0
for p in ps:
    minNum = min(minNum, p)
    if minNum == p:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = [int(i) for i in input().split()]

ans = 1
tmp = p[0]
for i in range(1, n):
    if tmp >= p[i]:
        ans += 1
        tmp = p[i]
print(ans)

Submission status: Accepted

Solution code:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10**5+10
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n = int(input())
a = arrIN()

heap = []
heappush(heap,a[0])
ans = 1
for i in range(1,n):
    x = heappop(heap)
    if x>a[i]:
        ans+=1
    heappush(heap,x)
    heappush(heap,a[i])
print(ans)

Submission status: Accepted

Solution code:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def mniejsze_elementy(): 
    N = wczytaj_liste()[0]
    P = wczytaj_liste()
    odp = 1 
    najmniejszy_dotychczas = P[0]
    for i in range(1,N):
        if P[i]< najmniejszy_dotychczas: 
            odp += 1
            najmniejszy_dotychczas = P[i]
    print(odp)
    
mniejsze_elementy()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

n = int(input())
p = list(map(int, input().split()))

cur_min = p[0]
ans = 1
for k, v in enumerate(p):
    if k == 0: continue
    if v <= cur_min:
        ans += 1
    cur_min = min(cur_min, v)

print(ans)

Submission status: Accepted

Solution code:
# # Binary Indexed Tree (Fenwick Tree)
# class BIT:
#     def __init__(self, n):
#         self.n = n
#         self.data = [0]*(n+1)
#         self.el = [0]*(n+1)
#     def sum(self, i):
#         s = 0
#         while i > 0:
#             s += self.data[i]
#             i -= i & -i
#         return s
#     def add(self, i, x):
#         # assert i > 0
#         self.el[i] += x
#         while i <= self.n:
#             self.data[i] += x
#             i += i & -i
#     def get(self, i, j=None):
#         if j is None:
#             return self.el[i]
#         return self.sum(j) - self.sum(i)

# N = int(input())
# P = [int(i) for i in input().split()]

# res = 0
# bit = BIT(200010)
# for i, p in enumerate(P):
#     bit.add(p, 1)
#     res += 1 if bit.sum(p) <= 1 else 0
#     # print(bit.sum(p))

# print(res)
INF = 10**18

N = int(input())
P = [int(i) for i in input().split()]

minp = INF
res = 0
for p in P:
    if p < minp:
        minp = p
        res += 1
print(res)

Submission status: Accepted

Solution code:
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

N = int(input())
P = [int(i) for i in input().split()]

res = 0
bit = BIT(200010)
for i, p in enumerate(P):
    bit.add(p, 1)
    res += 1 if bit.sum(p) <= 1 else 0
    # print(bit.sum(p))

print(res)

Submission status: Accepted

Solution code:
p_num = int(input())
p = list(map(int,input().split()))

count = 1
min_num = p[0]


for i in p[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)

Submission status: Accepted

Solution code:
def c_low_elements():
    import numpy as np
    N = int(input())
    P = np.array(input().split(), np.int32)
    return np.count_nonzero(P == np.minimum.accumulate(P))

print(c_low_elements())

Submission status: Accepted

Solution code:
def c_low_elements():
    import numpy as np
    N = int(input())
    P = np.array(input().split(), np.int32)
    Q = np.minimum.accumulate(P)
    return np.count_nonzero(P == Q)

print(c_low_elements())

Submission status: Accepted

Solution code:
N = int(input())
List = [int(x) for x in input().split()]

cnt = 1
min_num = List[0]

for i in List[1:]:
    if i < min_num:
        min_num = i
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

ans = 0
mn = INF
for a in A:
    if a < mn:
        mn = a
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class BIT:
    """ Binary Indexed Tree """

    def __init__(self, n):
        # 0-indexed
        n += 1
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

N = INT()
A = LIST()

bit = BIT(N)
ans = 0
for i in range(N):
    # 自分より左にある、自分より小さな数の個数
    if bit.sum(A[i]) == 0:
        ans += 1
    bit.add(A[i], 1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
nums = [int(i) for i in input().split()]

cnt = 1
min_num = nums[0]
for num in nums[1:]:
    if num < min_num:
        min_num = num
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

mins = [P[0]]
for i in range(1, N):
    x = min(mins[-1], P[i])
    mins.append(x)

# print(mins)

c = 0
for i in range(N):
    if P[i] <= mins[i]:
        c += 1

print(c)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
cnt = 1 # P[0] is counted forcely
min_num = P[0]
for p in P:
  if p < min_num:
    min_num = p
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

mn = N+1
c = 0
for pi in P:
    if pi <= mn:
        c += 1
        mn = pi

print(c)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
count = 1
min_p = p[0]
for i in range(n):
    if min_p > p[i]:
        count += 1
        min_p = p[i]
print(count)

Submission status: Accepted

Solution code:
N = int(input())

P = list(map(int, input().split()))

n_max = P[0]
cnt = 1

for i in range(1, N):
    if n_max > P[i]:
        cnt += 1
        n_max = P[i]

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
minVal = max(p)
for i in range(n):
    minVal = min(minVal, p[i])
    if p[i] <= minVal:
        cnt += 1
    else:
        continue
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
lowe, min_an_sub = 0, an[0]
an_sub = []
for i in range(0, n):
    an_sub.append(an[i])
    min_an_sub = min(min_an_sub, an[i])
    if an_sub[i] <= min_an_sub:
        lowe += 1
print(lowe)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

smallest_so_far = float("inf")
cnt = 0

for the_num in P:
    if the_num < smallest_so_far :
        smallest_so_far = the_num
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
N=int(input())
P=list(map(int,input().split()))
mn=10**6
cnt=0
for i in range(N):
    if P[i]<=mn:
        mn=P[i]
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
minimum = l[0]
ans = 0
for i in range(n):
    if l[i] <= minimum:
        ans += 1
    minimum = min(minimum, l[i])

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
N=int(input())
P=list(map(int,input().split()))
mn=P[0]
cnt=1
for i in range(1,N):
    if P[i]<=mn:
        mn=P[i]
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
N = a+1
ans = 0
 
for i in range(a):
  c = b[i]
  if c<N:
    ans += 1
    N = c
    
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
P=list(map(int,input().split()))
count=1
min=P[0]
for i in range(1,N):
    if min>P[i]:
      count+=1
      min=P[i]
print(count)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
count = 0
m = [0] * n

memo = n
for i in range(n):
    if memo > p[i]:
        m[i] = p[i]
        memo = p[i]
    else:
        m[i] = memo

for i in range(1, n+1):
    if p[i-1] <= m[i-1]:
        count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
ans = 0
mini = n
for i in p:
    if i <= mini:
        ans += 1
        mini = i 
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
r = 1
m = a[0]
for i in a[1:]:
  if m >= i:
    r += 1
  m = min(i, m)
print(r)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
ans = 0
list_a=[]
min = p[0]
for i in p:
  if min >= i:
    min = i
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
class SWAG():
    __slots__='unit','f','fold_r','fold_l','data_r','data_l'
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.construct(data)
    def construct(self,data):
        self.fold_r=[self.unit]
        self.fold_l=[self.unit]
        self.data_r=[]
        self.data_l=[]
        sep=0--len(data)//2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep-1::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        if not self.data_r:
            return self.popleft()
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        if not self.data_l:
            return False
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,*p=map(int,open(0).read().split())
swag=SWAG(10**18,min,[])
a=0
for p in p:
    if p<swag.fold_all():
        a+=1
    swag.append(p)
print(a)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))

minp = P[0]
ans = 0

for i in range(N):
    minp = min(minp,P[i])
    if minp == P[i]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
P = [int(i) for i in input().split()]
min_ = 9999999999
ans = 0
for i in range(N):
    
    min_ = min(P[i], min_)

        
    if P[i] == min_:
        #print(P[i], i_max)
        ans += 1
    
    #if not flag:
    #    ans += 1
#print(ans.keys())
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
P=list(map(int,input().split()))

count=1
base=P[0]

for i in range(1,N):
    if P[i]<=base:
        base=P[i]
        count+=1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
p_list = list(map(int, input().split(' ')))

m = p_list[0]
count = 1
for p in p_list:
  if p < m:
    count += 1
    m = p
print(count)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

cnt = 0

maxmax = max(P) + 1

for i in range(N):
  if( maxmax > P[i]):
    cnt += 1
    maxmax = P[i]
  
print(cnt)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    min_num = n+1
    for i in p:
        if i < min_num:
            min_num = i
            count += 1
    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))

minVal = 2*10**5+1
cnt = 0
for i in range(n):
  if p[i] < minVal:
    minVal = p[i]
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
cnt = 0
t = p[0]

for i in range(n):
    if t >= p[i]:
        cnt += 1
        t = p[i]


print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))

ans = 0
mins = [10**6]
for i in P:
    v = min(mins[-1], i)
    mins.append(v)
mins.pop(0)

ans = 0
for i, j in zip(P, mins):
    if i <= j:
        ans += 1
print(ans)