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:
n = int(input())
A = list(map(int, input().split(' ')))

mi = [A[0]]
for i in range(1, n):
    if mi[i-1] > A[i]:
        mi.append(A[i])
    else:
        mi.append(mi[i-1])

#print(mi)

c = 1
for i in range(1, n):
    if A[i] <= mi[i]: c+=1

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
m = 2 * (10 ** 5) + 1
for i in range(N):
    if m >= A[i]:
        ans += 1
        m = A[i]

print(ans)

Submission status: Accepted

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

Min = N+1
n = 0
for i in range(N):
  if Min > a[i]:
    Min = a[i]
    n += 1
  
print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
ans = 1 #i=1は絶対満たす
now_min = p[0]
for i in range(1,n):
    if p[i] <= now_min:
        ans+=1
        now_min = p[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
min_value = 2e5+1

for p in P:
	if p <= min_value:
		min_value = p
		count += 1

print(count)

Submission status: Accepted

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

count = 0
minL = pList[0] 
for i in range(n):
  if minL >= pList[i]:
      count += 1
      minL = pList[i] 
      if minL == 1:
        break

print(count)

Submission status: Accepted

Solution code:
n = int(input())
permutation = [int(x) for x in input().split()]
minimum, count = permutation[0], 0  # init

for p_i in permutation:
  
  if p_i > minimum:
    count += 1
  else:
    minimum = p_i
    
print(n - count)

Submission status: Accepted

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

MIn, MAn = [float("inf")] * N, [-float("inf")] * N
mi, ma = float("inf"), -float("inf")
for i in range(N):
    mi = min(mi, Pn[i])
    ma = max(ma, Pn[i])

    MIn[i], MAn[i] = mi, ma

ans = 1
for i in range(N):
    if Pn[i] == MIn[i] and Pn[i] < MAn[i]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
P = [int(x) for x in input().split()]
mins = [0]*N
mins[0] = P[0]
for n in range(1,N):
    mins[n] = min(P[n],mins[n-1])
ans = 0
for i in range(N):
    if P[i] == mins[i]:
        ans += 1
print(ans)

Submission status: Accepted

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

ans = 1
base = p[0]

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
minimum = P[0]

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

Submission status: Accepted

Solution code:
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([4, 2, 5, 1, 3]), 3)

    def test_2(self):
        self.assertEqual(think([4, 3, 2, 1]), 4)

    def test_3(self):
        self.assertEqual(think([1, 2, 3, 4, 5, 6]), 1)

    def test_4(self):
        self.assertEqual(think([5, 7, 4, 2, 6, 8, 1, 3]), 4)

    def test_5(self):
        self.assertEqual(think([1]), 1)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(p):
    dp = [0 for _ in range(len(p) + 1)]
    count = 1
    dp[1] = p[0]
    for i in range(1, len(p)):
        if p[i] <= dp[i]:
            count += 1
            dp[i + 1] = p[i]
        else:
            dp[i + 1] = dp[i]
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

cnt=0

import numpy as np

P=np.array(P)

max_val=P[0]

cnt=1

for i in range(1,N):
    if max_val > P[i-1]:
        max_val=P[i-1]

    if max_val > P[i]:
        cnt+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
P = [int(x) for x in input().split()]
Min, count = N+1, 0
for _ in range(N):
    if P[_] < Min:
        count += 1
        Min = P[_]
print(count)

Submission status: Accepted

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

min = p[0]
c=0
for i in p:
    if min >=i:
        min = i
        c+=1

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    P = list(map(int, input().split(" ")))
    minimum = 10 ** 6
    result = 0
    for p in P:
        if minimum > p:
            result += 1
            minimum = p
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
p=[int(x) for x in input().split()]
s=0
t=n+1
for c in range(n):
    if p[c]<t:
        s+=1
        t=p[c]
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0
min1 = L[0]
for i in range(n-1):
    min1 = min(min1,L[i])
    if L[i+1]<=min1:
        #print(L[i+1])
        cnt +=1
print(cnt+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

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 Min >= p[i]:
        Min = p[i]
        count += 1

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
ANS=0
#MIN_L=[L[0]] * N
TMP_MIN = L[0]
#print(MIN_L)
for i in range(0,N):
  #print(TMP_MIN, L[i])
  if TMP_MIN >= L[i]:
    TMP_MIN = L[i]
    ANS += 1    
print(ANS)

Submission status: Accepted

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

ans = 0
minp = p[0]

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

print(ans)

Submission status: Accepted

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

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


print(cnt)

Submission status: Accepted

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

mx = 10 ** 19
ans = 0
for i in p:
  if i < mx:
    mx = i
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def print_ans(N, P):
    """Test Case
    >>> print_ans(5, [4, 2, 5, 1, 3])
    3
    >>> print_ans(4, [4, 3, 2, 1])
    4
    >>> print_ans(6, [1, 2, 3, 4, 5, 6])
    1
    >>> print_ans(8, [5, 7, 4, 2, 6, 8, 1, 3])
    4
    >>> print_ans(1, [1])
    1
    """
    min_num = P[0]
    counter = 1
    for i in range(1, N):
        if min_num >= P[i]:
            counter += 1
        min_num = min(min_num, P[i])
    print(counter)



if __name__ == '__main__':
    N = int(input().rstrip())
    P = list(map(int, input().rstrip().split()))
    print_ans(N, P)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	P = inputList()

	ans = 0
	mmin = 0
	for i,val in enumerate(P):
		if i == 0:
			ans += 1
			mmin = val
			continue

		if val <= mmin:
			ans += 1
			mmin = val
			#print("{} {} {}".format(i,val,mmin))
		else:
			pass

	print(ans)



if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))
#その値より左の数字を比較して、一番小さいやつが当てはまる。


Ans = 0
min = N

for i in range(N):
    if min >= P[i]:
        min = P[i]
        Ans = Ans +1
        #print("そうやで")
    #else:
        #print("ちがうやで")

print(Ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
lst = list(map(int,input().split()))
mi = lst[0]
ans = 1

for i in range(1,N):
  if (mi > lst[i]):
    ans += 1
    mi = lst[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
min_p = 2 * 10 ** 5 + 1
for i in p:
    if i <= min_p:
        cnt += 1
        min_p = i
print(cnt)

Submission status: Accepted

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

m = N + 1
cnt = 0

for p in P:
    if p < m:
        cnt += 1
        m = p

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

count=1
temp=pl[0]
l=[pl[0]]
for i in range(1,n):
    if pl[i]<temp:
        temp=pl[i]
        l.append(temp)
    else:
        l.append(temp)
    if pl[i]<=temp:
        count+=1
print(count)

Submission status: Accepted

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

num = 0
num_min = 2 * 10**5 + 1
i = 0

while i < N:
  if num_min >= int(P[i]):
    num += 1
    num_min = int(P[i])
  i += 1

print(num)

Submission status: Accepted

Solution code:
import sys

N = int(input())
P = [int(v) for v in input().split()]
cnt = 0
M = 3 * 10 ** 5
for i in range(N):
    if M > P[i]:
        cnt += 1
    M = min(M,P[i])
print(cnt)

Submission status: Accepted

Solution code:
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
p=[int(i) for i in input().split()]
ans=1
m=p[0]
for i in range(1,n):
    if p[i]<=m: ans+=1
    m=min(m,p[i])
        
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ps = list(map(int, input().split()))
    ans = 0
    minp = float("inf")
    for p in ps:
        minp = min(minp, p)
        if minp >= p:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
smallest = 1

for i in range(n):

    if i == 0:
        sum += 1
        smallest = arr[i]
    else:
        if arr[i] > smallest:
            continue
        else:
            smallest = arr[i]
            sum += 1

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
l = [float('inf')] * N
for i in range(1, N):
  l[i] = min(P[i - 1], l[i - 1])
cnt = 0
for i in range(N):
  if l[i] > P[i]:
    cnt += 1
print(cnt)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())
PP = list(map(int,input().split()))
# print(PP)
mp = PP[0]
count = 0
for i in range(N):
    if PP[i] <= mp:
        count += 1
        mp = PP[i]
    else:
        pass

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

result = []
c = 0
smallest = p[0]
for i in range(0,n):
    flag = 0
    if smallest >= p[i]:
        c += 1
        smallest = p[i]

print(c)

Submission status: Accepted

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

count = 1
min_e = pl[0]
for e in pl[1:]:
    if (e < min_e):
        count += 1
        min_e = e
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    P = list(map(int, input().split()))
    
    count = 0
    k = 0
    for i in range(N):
        flag = True
        for j in range(k, i):
            if P[i] > P[j]: 
                flag = False
                break

        if flag:
            count += 1
            k = i
            
    print(count)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]

N = int(fetch_one_line())
nums = fetch_int_input()

min_num = 999999999999999999
count = 0

for num in nums:
    if min_num >= num:
        count += 1
        min_num = num

print(count)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.buffer.readline

N = int(readline())
P = list(map(int, readline().split()))

M = P[0]
cnt = 0

for p in P:
    if p <= M:
        cnt += 1
        M = min(p, M)

print(cnt)

Submission status: Accepted

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

ret = 0
m = 9999999999
for i, n in enumerate(P):
    if n <= m:
        ret += 1
        m = n
print(ret)

Submission status: Accepted

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

min_dp = [-1] * N

min_dp[0] = P[0]

ans = 1
for i in range(1, N):
    if(P[i] <= min_dp[i-1]):
        min_dp[i] = P[i]
        ans += 1
    else:
        min_dp[i] = min_dp[i-1]

print(ans)

Submission status: Accepted

Solution code:
# 個数を返す

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

_min = ps[0]
mins = []
for p in ps:
    if p < _min:
        _min = p
    mins.append(_min)

count = 0
for i in range(n):
    if ps[i] <= mins[i]:
        count+=1

print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 0
p_min = P[0]

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

    if P[i] < p_min: 
        p_min = P[i]

print(cnt)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    mintmp = n+1
    ans = 0
    for i, v in enumerate(a):
        if v <= mintmp:
            ans += 1
            mintmp = v
    print(ans)

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
p = [int(i) for i in input().split()]
m = [p[0]] * n
if n > 1:
	for i in range(1, n):
		m[i] = min(m[i-1], p[i])
ans = 0
for i in range(n):
	if p[i] == m[i]:
		ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1
chk = P[0]

for p in P:
    if p < chk:
        cnt += 1
        chk = p

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
i=0
a=1
min=p[0]
while True:
  if min>p[i]:
    min=p[i]
    a+=1    
  if p[i]==1:
    break
  i+=1
print(a)

Submission status: Accepted

Solution code:
N = int(raw_input())
P = map(int, raw_input().split())
#print N, P
n = 0
cmin = P[0]
for i in range(N):
    if P[i] <= cmin:
        n += 1
        cmin = P[i]

print n

Submission status: Accepted

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

total = 0

equi = P_i[0]

for i in range(N):
    if equi >= P_i[i]:
        total += 1
        equi = P_i[i]

print(total)

Submission status: Accepted

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

min_val=float("inf")

ans=0
for x in P:
    if x<=min_val:
        min_val=x
        ans+=1
print ans

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:04:49 2020

@author: masat
"""

N = int(input())

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

#print(P_list)

min_Pj = P_list[0]
counter = 0
for Pi in P_list:
    min_Pj = min(min_Pj, Pi)
    #print(min_Pj)
    if Pi <= min_Pj:
        counter += 1
    else:
        pass

print(counter)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
INF = 500000
mod = 10**9+7

N = int(input())
A = [int(x) for x in input().split()]
M = INF
ans = 0
for a in A:
    if a < M:
        ans += 1
        M = a
print(ans)

# N = int(input())
# dic = defaultdict(lambda : 0)
# for i in range(1, 10):
#     for j in range(1, 10):
#         if i == j:
#             if i <= N:
#                 dic[(i, j)] = 1
#         for k in range(1, 6):
#             x = i*10**k + j
#             if

Submission status: Accepted

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

Submission status: Accepted

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

_min = p[0]
ans = 0

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

	
	ansl = []
	ansl.append(a[0])
	i = 1
	if n == 1:
		pass
	elif a[0] >= a[1]:
		ansl.append(a[1])

	while i < n:
		if ansl[-1] > a[i]:
			ansl.append(a[i])
		i += 1
	print(len(ansl))


	

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

min_value = number[0]

ans = 0

for p in number:
    if p <= min_value:
        ans += 1
        min_value = p
    

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
c = 0
i = 0
temp_min = p[i]
while i < n:
  if p[i] <= temp_min:
    c = c + 1
    temp_min = p[i]
  i = i + 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    P = list(map(int, args[1].split()))

    count = 0
    small = P[0]
    for i in range(n):
        if P[i] <= small:
            count += 1
        small = min(small, P[i])

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

Solution code:

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

count = 0
value = 0

for i, value in enumerate(P):

    if i == 0:
        count += 1
        m = value
        continue

    elif m >= value:
        m = value
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1
min = P[0]
flag = True

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

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

t = []
t = list(map(int, input().split()))

count = 0
min = t[0]

for i in t:
    if i <= min:
        count = count + 1
        min = i
#        print("c:{}".format(i))
#    else:
#        print("NG:{}".format(i))
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

count = 1 # 最初の数は入れる

flag = L[0]

for i in range(1,N):
    if L[i] <= flag:
        count += 1
        flag = L[i]
        if flag == 1:
            break
    

print(count)

Submission status: Accepted

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

mi = P[0]
cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
import heapq


def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    heap = []
    ans = 0
    for i in range(n):
        heapq.heappush(heap, p_list[i])
        if heap[0] >= p_list[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

l = []
l.append(p[0])
temp = p[0]
for i in range(0, n-1):
  if p[i+1] < temp:
    temp = p[i+1]
    l.append(p[i+1])
    
print(len(l))

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
num_list = [int(i) for i in stdin.readline().rstrip().split()]
output = 0
min_value = float("inf")
for n in range(0, N):
    now_value = num_list[n]
    if min_value > now_value:
        output += 1
        min_value = now_value
    # over_list = [i for i in num_list[:n] if i > now_value]
    # if len(over_list) == len(num_list[:n]):
    #     output += 1
print(output)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

"""
count = 0
for i in range(N):
	flag = 1
	for j in range(i):
		if P[i] <= P[j]:
			flag = 1
		else:
			flag = -1
			break

	if flag == 1:
		count += 1

print(count)
"""
count = 0
min_ = P[0]
for p in P:
	if p <= min_:
		count += 1
		min_ = p

print(count)

Submission status: Accepted

Solution code:
import sys
bbn=1000000007
	
#+++++

		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	count=0
	pre_max=al[0]
	for v in al:
		pre_max = min(v, pre_max)	
		if pre_max >= v:
			count+=1
	print(count)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

count = 1
minval = lstP[0]

for i in range(1, len(lstP)):
    val = lstP[i]
    if val <= minval:
        minval = val
        count += 1

print(count)

Submission status: Accepted

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