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:

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()



def main():
    N = iRaw()
    Ps = isRaw()
    ni =0
    curMin = N+1
    for i,p in enumerate(Ps):
        if p <= curMin:
            ni+=1
            curMin = p
    return ni


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

Submission status: Accepted

Solution code:

N = int(input())
b = list(map(int, input().split()))
# print(a)
# print(b)
mini = 1000000
ans = 0
for i in range(N):
    if b[i] < mini:
        mini = b[i]
        ans += 1
    if b[i] == 1:
        break

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n=int(input())
p=list(map(int,input().split()))
count=1
minnum=p[0]
for i in range(1,len(p)):
    if p[i]<=minnum:
        minnum=p[i]
        count+=1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
sta = list(map(int, input().split()))
min_i = sta[0]
count_i = 0
for i in sta:
    if min_i > i:
        min_i = i
    if i <= min_i:
        count_i += 1

print(count_i)

Submission status: Accepted

Solution code:

class Solution:
    def solve(self, n, arr):
        count = 1
        minElement = arr[0]

        for i in range(1, n):
            if arr[i] <= minElement:
                count += 1
                minElement = arr[i]

        return count


sol = Solution()

n = int(input().strip())
arr = list(map(int, input().strip().split(" ")))

print(sol.solve(n, arr))

Submission status: Accepted

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

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

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

print(count)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

minVal = p[0]
cnt = 1

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

print(cnt)

Submission status: Accepted

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

counter = 0
min = N_list[0]
for i in range(N):
    if N_list[i] <= min:
        min = N_list[i]
        counter += 1
print(counter)
print()

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().strip().split()))
mn = n + 1
cnt = 0
for pi in p:
    if pi < mn:
        cnt += 1
        mn = pi

print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
min_p = ps[0]
for i in range(0,n):
  if ps[i] <= min_p:
    result += 1
    min_p = ps[i]
print(result)

Submission status: Accepted

Solution code:
class Solution:
#    def solve(self, N: int, P: List[int]) -> int:
    def solve(self, N, P) :
        max_p = N
        answer = 0

        for pn in P:
            if pn <= max_p:
                answer += 1
                max_p = pn

        return answer


if __name__ == '__main__':

    # standard input
    N = int(input())

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

    # solve
    solution = Solution()
    print(solution.solve(N, P))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
P = deque(list(map(int, input().split())))
ans, tmp, minnum = 0, 0, pow(10,9)
Array = []

for i in range(N):
    tmp = P.popleft()
    Array.append(tmp)
    if tmp < minnum:
        minnum = tmp
    if Array[-1] == minnum:
        ans += 1
print(ans)

Submission status: Accepted

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

Pn_min = Pn[0]
count = 0
for i in range(N):
    if(Pn[i] <= Pn_min):
        count = count + 1
        Pn_min = Pn[i]
print(count)

Submission status: Accepted

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

print (cnt)

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int, input().split()))
ans = 0
min_here = 3 * 10 ** 5
for ele in arr:
    if min_here > ele:
        ans += 1
    min_here = min(min_here, ele)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
p_list = _li()

cur_min = 10**7
count = 0
for p in p_list:
    if p <= cur_min:
        count += 1
    if p < cur_min:
        cur_min = p
print(count)

Submission status: Accepted

Solution code:
"""
can do it by subproblems. for a given i, the only information you need from the previous values
is the min value of previous values.
the first i=0 is guaranteed to satisfy the constraint. (counting from zero).
"""
import sys


def count_low_elements(N, P):
    count = 0
    min_so_far = sys.maxsize
    for val in P:
        if val <= min_so_far:
            count += 1
            min_so_far = val
    return count


if __name__ == "__main__":
    test1 = \
"""5
4 2 5 1 3"""
    test2 = \
"""4
4 3 2 1"""
    test3 = \
"""6
1 2 3 4 5 6"""
    test4 = \
"""8
5 7 4 2 6 8 1 3"""
    test5 = \
"""1
1"""
    test = test5
    # N, P_string = test.split("\n")
    # P = list(map(int, P_string.split()))
    N = int(input())
    P = list(map(int, input().split()))
    print(count_low_elements(N, P))

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
ans=0
prev=float('inf')
for l in L:
  if l<prev:
    ans+=1
    prev=l
  else:
    continue
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  now = n+1
  times = 0
  for i in range(n):
    value = p[i]
    if now >= value:
      times += 1
    now = min(value,now)
  print(times)
    
solve()

Submission status: Accepted

Solution code:
n = input()
arr = [int(x) for x in input().split()]
min_num = arr[0]
i = 0
for x in arr:
  if x <= min_num:
    i += 1
    min_num = x
print(i)

Submission status: Accepted

Solution code:
N = int(input())
lst1 = [int(x) for x in input().split()]
a = lst1[0]
ret = 0
for x in lst1:
    a = min(a, x)
    if x <= a:
        ret += 1
print(ret)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())
p = [int(e) for e in input().split(" ")]
low = p[0]
c = 0
for i in range(N):
    if(p[i] <= low):
        c += 1
        low = p[i]
print(c)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

minv = float('inf')
cnt = 0
for v in a:
    if minv > v:
        minv = v
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
i = int(input())
j = [int(x) for x in input().split()]

m = j[0]
count = 0
for x in range(i):
    if m >= j[x]:
        count += 1
        m = j[x]
print(count)

Submission status: Accepted

Solution code:

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

count = 0
m = P[0]
for i in range(n):
    if P[i] <= m:
        count += 1
        m = P[i]
print(count)

Submission status: Accepted

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

min = Pn[0]
count = 0

# 1より右側は探索不要
Pn = Pn[:Pn.index(1)+1]

for i in range(len(Pn)):
    if min >= Pn[i]:
        # print("min:{} Pi:{}".format(min,Pn[i]))
        count += 1
        min = Pn[i]

print(count)

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
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 pf(s): return print(s, flush=True, end="")

N = _I()
X=LI()
ans=0

lowest=X[0]
for x in X:
	if x <= lowest:
		ans+=1
		lowest=x
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(sys.stdin.readline())
nums = [int(x) for x in sys.stdin.readline().split()]
 
ans = 0
_min = float('inf')
for num in nums:
  if _min >= num:
    ans += 1
  _min = min(_min, num)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from operator import itemgetter
import collections

def r(n, p):
  m = n + 1
  count = 0
  for i in range(n):
    m = min([p[i], m])
    if m == p[i]:
      count += 1
  return count

def main():
    input = sys.stdin.readline
    n = int(input())
    p = list(map(int, input().split()))
    print(r(n,p))

    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
pjmin = P[0]
for pi in P:
    if pi <= pjmin:
        cnt +=1
        pjmin = pi
        if pi ==1:
            break
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int( input())
    P = list( map( int, input().split()))
    ans = 0
    now = P[0]
    for p in P:
        if now >= p:
            ans += 1
            now = p
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

min_ = float("inf")
c = 0
for i in range(n):
    if A[i] < min_:
        min_ = A[i]
        c += 1
print(c)

Submission status: Accepted

Solution code:
N = int(input())
P = [int(s) for s in input().split()]

min_value = P[0]
ans_count = 0
for i in range(len(P)):
    if P[i] <= min_value:
        ans_count += 1

    min_value = min(min_value, P[i])

print(ans_count)

Submission status: Accepted

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

count = 0
min_p = N + 1
for p in P:
    min_p = min(min_p, p)
    if p <= min_p:
        count += 1

print(count)

Submission status: Accepted

Solution code:
N, = list(map(int,input().split()))
P = list(map(int,input().split()))
c = 0
m = N+1
for pi in P:
    c += 1 if pi<=m else 0
    m = min(m, pi)
print(c)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
ans = 0
min=2*100000

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, P):
    min_val = P.pop(0)
    count = 1
    for p in P:
        if min_val >= p:
            count += 1
        if min_val > p:
            min_val = p
    return count

_n = int(input())
_P = list(map(int, input().split()))
print(solve(_n, _P))

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    arr = tuple(map(int, input().split()))
    tmp = arr[0]
    counter = 0
    for i in arr:
        if i<=tmp:
            tmp=i
            counter += 1
    print(counter)
 
if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

ans = 1
tempmin = P[0]
for i in range(1,N):
  if tempmin >= P[i]:
    tempmin = P[i]
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
l = input().split(" ")
P = [int(n) for n in l]

# i=1は必ずOK
c = 1
min = P[0]

for i in range(1,N):
  p = P[i]
  if p<=min:
    c+=1
    min=p
    
print(c)

Submission status: Accepted

Solution code:
import sys
lines = [l.rstrip() for l in sys.stdin.readlines()]
n = int(lines[0])
l = [int(e) for e in lines[1].split(" ")]

min = n
c = 0
for e in l:
    if e < min:
        min = e
    if min >= e:
        c += 1

print(c)

Submission status: Accepted

Solution code:
a=int(input())
b=list(map(int,input().split()))
ans=0
k=10**9+7
for i in range(a):
  if k>=b[i]:
    ans+=1
    k=b[i]
print(ans)

Submission status: Accepted

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

flag = True
pre_min_p = p[0]
cnt = 0
for i in p:
    if pre_min_p >= i:
        cnt += 1
        pre_min_p = i

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
  if p[i] <= min:
    count += 1
    min = p[i]
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

q = p[0]
p = p[1:]

m = 1

if n > 1:
    for pi in p:
        if q > pi:
            m += 1
            q = pi

print(m)

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 mi>=P[i]:
        cnt+=1
        mi=P[i]
print(cnt)

Submission status: Accepted

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

count = 1
min = P_list[0]
for i in range(1, len(P_list)):
    if P_list[i] <= min:
        count += 1
        min = P_list[i]
print(count)

Submission status: Accepted

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

ans = 0
now = 10 ** 6

for p in P:
    if p <= now:
        ans += 1
        now = p

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
lis=list(map(int,input().split()))
min=float('inf')
ans=0
for i in lis:
  if min>=i:
    ans+=1
    min=i
print(ans)

Submission status: Accepted

Solution code:
def solve(n, P):
  min_val = P.pop(0)
  count = 1
  for p in P:
    if min_val >= p:
      count += 1
    if min_val > p:
      min_val = p
  return count

_n = int(input())
_P = list(map(int, input().split()))
print(solve(_n, _P))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
N = int(input())
P = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

num = p[0]
ans = 1

for i in range(1,n):
    if num >= p[i]:
        ans += 1
    num = min(p[i], num)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
m = N
for p in P:
  m = min(m, p)
  if p <= m:
    count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
li = [int(zz) for zz in input().split()]

ans = 0
tmp = 10**9
for i in range(N):
    if li[i] < tmp:
        tmp = li[i]
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

counter = 0

min = Pn[0]

for i in range(N):
  if Pn[i] <= min:
    counter += 1
    min = Pn[i]
  else:
    pass

print(counter)

Submission status: Accepted

Solution code:
n = int(input())
data = [int(i) for i in input().split()]
pre = data[0]
ans = 0

for now in data:
  if now <= pre:
    pre = now
    ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
seq = [int(e) for e in input().split(' ')]

count = 1

current_min = seq[0]

for idx, i in enumerate(seq[1:]):
  if i < current_min:
    current_min = i
    count += 1
print(count)

Submission status: Accepted

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

min = 0
cnt = 0
for i in range(N):
  if i == 0:
    cnt += 1
    min = A[i]
    continue
  if A[i] <= min:
    cnt += 1
    min = A[i]

print(cnt)

Submission status: Accepted

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

cnt=0
min=int(p[0])
for i in p:
  if int(i)<=min:
    cnt=cnt+1
    min=int(i)
print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

maxs = 1000000000000
cnt = 0
for i, s in enumerate(S):
  if maxs > s:
    cnt += 1
    maxs = s
    
print(cnt)

Submission status: Accepted

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

count = 0

minimum = Ps[0]

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

print(count)

Submission status: Accepted

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

ac = list(itertools.accumulate(P, min))
ok = [P[i] <= ac[i] for i in range(len(P))]
print(ok.count(True))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]
mx=10**10
cnt=0
for i in a:
  mx=min(mx,i)
  if mx>=i:
    cnt+=1
print(cnt)

Submission status: Accepted

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

#output
import heapq as hp
Q = []
answer = 0
for i in range(N):
    hp.heappush(Q, P[i])
    temp = hp.heappop(Q)
    hp.heappush(Q, temp)
    if temp == P[i]:
        answer += 1

print(answer)

Submission status: Accepted

Solution code:
n = int(input())
low = 0
lowest_seen = n + 1
for i in input().split():
    i = int(i)
    if i < lowest_seen:
        lowest_seen = i
        low += 1

print(low)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt =1
for i in range(input_N-1):
    if p_list[i] > p_list[i+1]:
        cnt += 1
    else:
#         print(i)

        p_list[i+1] = p_list[i]
        
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
P = map(int, input().split(' '))
r = 0
min = 999999
for p in P:
    if p < min:
        r += 1
        min = p
print(r)

Submission status: Accepted

Solution code:
iterate = int(input())
p = [int(x) for x in input().split()]

result_sum = 0
prev_min = 10  ** 9
for i in range(iterate):
  if p[i] <= prev_min:
    	result_sum += 1
  prev_min = min(prev_min, p[i])

print(result_sum)

Submission status: Accepted

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

ans=0
minCount=2*10**6

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

print(ans)

Submission status: Accepted

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

x = P[0]
ans = 0

for i , val in enumerate(P):
    if val <= x:
        x = val
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
total = int(input())
array = list(map(int, input().split()))

min = 0
ans = 0
for i,num in enumerate(array):
    if i == 0:
        min = num
        ans += 1
    else:
        if num < min:
            min = num
            ans += 1

print(ans)

Submission status: Accepted

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


def solve(N: int, P: "List[int]"):
    smallest = 2 * 10**6
    count = 0
    for p in P:
        if p <= smallest:
            count += 1
            smallest = p
    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

answer = 0
mi = -1
for idx, p in enumerate(li_p):
    if idx == 0:
        mi = p
        answer += 1
    else:
        if p <= mi:
            answer += 1
        mi = min(mi, p)
print(answer)

Submission status: Accepted

Solution code:
n=int(input())
c=list(map(int,input().split()))
minimum=100000000
count=0
for i in range(len(c)):
    if c[i]<minimum:
        minimum=c[i]
    if c[i]<=minimum:
        count+=1
print(count)

Submission status: Accepted

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

cnt = 1
m = P[0]

for p in P[1:]:
    if m > p:
        cnt += 1
    m = min(m, p)
print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

min = 9999999
ans = 0

for x in p:
  if x <= min:
    ans = ans+1 
    min = x
  
print(ans)

Submission status: Accepted

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

Max = Num[0]
Min = Num[0]
cnt  = 1
for i in range(1,N):
    if Num[i] <= Max and  Min>=Num[i] :
        cnt +=1
        
    Max = max(Max,Num[i])
    Min = min(Min,Num[i])
    #print(Max,Min)
print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
P = [int(_) for _ in stdin.readline().rstrip().split()]
max = P[0]
ans = 0
for p in P:
    if p <= max:
        ans += 1
        max = p
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = map(int,input().split())
ans = 0
for i in (l):
    if n >= i:
        ans += 1
        n = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

min = 2*(10**5) + 1
cnt = 0

for i in range(n):
  if p[i] < min:
    min = p[i]
    cnt += 1
print(cnt)

Submission status: Accepted

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

ans = 1
mi = row[0]

for i in range(1,N):
  if row[i] < mi :
    ans+=1
    mi = row[i]
  else :
    continue
    
print(ans)

Submission status: Accepted

Solution code:
N=int(input())+1
A=map(int,input().split())
ans=0
for a in A:
    if N>a:
        ans+=1
    N=min(N,a)
print(ans)

Submission status: Accepted

Solution code:
N, *P = map(int, open(0).read().split())

ret = 0
min_value = float("inf")
for P_i in P:
  min_value = min(min_value, P_i)
  if min_value == P_i:
    ret += 1
    
print(ret)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
m = 10 ** 9 + 7
ret = 0
for i in range(N):
    m = min(m, P[i])
    if m == P[i]:
        ret += 1
print(ret)

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
P = np.array(lr(), np.int32)
P_min = np.minimum.accumulate(P)

answer = np.count_nonzero(P_min >= P)
print(answer)

Submission status: Accepted

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
P = np.array(lr())
P_min = np.minimum.accumulate(P)

answer = np.count_nonzero(P_min >= P)
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 0
min_num = numbers[0]
for i, n in enumerate(numbers):
    if min_num >= n:
        cnt += 1
        min_num = n
    
    if n == 1:
        break
        
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
input()
nums = map(int, input().split())
count = 0
min_sofar = float('inf')
for num in nums:
  if num <= min_sofar:
    count += 1
    min_sofar = num
print(count)

Submission status: Accepted

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

mn = int(1e9)
ans = 0

for i in range(n):
    if p[i] <= mn:
        ans += 1
        mn = p[i]

print(ans)

Submission status: Accepted

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