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())
P = [int(_) for _ in input().split()]

t = 0
j = 0

for i in range(N):
    while i >= j:
        if i == j:
            t += 1
            break
        elif P[i] >= P[j]:
            break
        else:
            j += 1
    

print(t)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int,input().split()))
 
cnt = 0
M = 10**6

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
P_list = input().split()
# N = '5'
# P_list = '4 2 5 1 3'.split()
P_list = [int(i) for i in P_list]
length = int(N)
ans = 0 
M = []
mini =-1
for i in range(length):
    # print(min(P_list[0:i+1]))
    if P_list[i] <mini or mini <0:
        mini = P_list[i]
    if mini == P_list[i]:
        ans +=1


    # if P_list[i]==min(P_list[0:i+1]):
    #     ans +=1
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
P = [int(n) for n in input().split()]
c = 0
curr = 2*10**5+1
for p in P:
    if p < curr:
        curr = p
        c += 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

min = 10000000000
count = 0
for i in range(n):
    if min >= int(p[i]):
        count += 1
    if min >= int(p[i]):
        min = int(p[i])

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


result=0

mm = 10**11

for pp in p:
    if pp <= mm:
        mm=pp
        result+=1

print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, P: "List[int]"):
    ans = [P[0]]
    
    for i in range(1, N):
        if P[i] < ans[-1]:
            ans.append(P[i])

    print(len(ans))

    return



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())
P = input().split()
counter = 0
m = N
for p in P:
    if int(m) >= int(p):
        counter +=1
        m = p
print(counter)

Submission status: Accepted

Solution code:
import math as mt
n=int(input())
a=list(map(int,input().split()))
ans=1001001
res=0
for i in range(n):
    if ans>a[i]:
        res+=1
        ans=min(ans,a[i])
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


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


myans = 0
mymin = 9999999999
for i in range(N):
    if mylist[i] < mymin:
        mymin = mylist[i]
        myans += 1
        
print(myans)

Submission status: Accepted

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

m = next(P)
c = 1
for p in P:
    if p <= m:
        m = p
        c += 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

counter=0
mj=N
for i in range(N):
  if mj>List[i]:
    mj=List[i]
  if List[i]==mj:
    counter+=1
print(counter)

Submission status: Accepted

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_right

sys.setrecursionlimit(10**7)
N = int(input())
P = list(map(int, input().split()))

cnt = 0
minv = P[0]
for p in P:
    minv = min(minv, p)
    if p == minv:
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def c_low_elements():
    N = int(input())
    P = [int(i) for i in input().split()]
    minimum = P[0]
    ans = 0
    for p in P:
        minimum = min(minimum, p)
        if minimum == p:
            ans += 1
    return ans

print(c_low_elements())

Submission status: Accepted

Solution code:
import math

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


best = pow(10,9)
count = 0

for i in range(len(data)):
    if data[i] < best:
        count += 1
        best = data[i]


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(map(int,input().split()))
counter = int(0)
minNum = S[0]

if N == 1:
  print("1")

else:
  for i in range(N):
    if minNum >= S[i]:
      minNum = S[i]
      counter = counter + 1
    
  print(counter)

Submission status: Accepted

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

ans = N
min_p = P[0]
for p in P[1:N]:
  if min_p > p:
    min_p = p
  else:
    ans -=1
print(ans)

Submission status: Accepted

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

count = 0
tmpmin = float('inf')
for pi in p:
    if pi < tmpmin:
        count += 1
    tmpmin = min(tmpmin, pi)
print(count)

Submission status: Accepted

Solution code:
n=int(input())
lists=list(map(int,input().split()))
 
mn=n+1
cnt=0
for li in lists:
  if mn>li:
    mn=li
    cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
array = list(map(int, input().strip().split()))
out = 0
min_num = array[0]
for i in array:
    min_num = min(min_num, i)
    out = out + 1 if i == min_num else out
print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
P_list = [int(e) for e in input().split()]

min_P = P_list[0]
ans = 0

for i in P_list:
  #print(i)
  
  if min_P >=i:
    #print("#")
    ans += 1
    min_P = i
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
P = [int(x) for x in input().split()]
pmin = max(P)
cnt = 0
for p in P:
  if p <= pmin:
    cnt += 1
    pmin = p
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

m = []
a = p[0]
for j in range(n):
    if a >= p[j]:
        a = p[j]
        m.append(a)
    else:
        m.append(a)

ans = 1
for i in range(n-1):
    if m[i] > m[i+1]:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
n, *ps = map(int, open(0).read().split())
mp = ps[0]
cou = 1
for p in ps[1:]:
  if mp > p:
    cou += 1
    mp = p
print(cou)

Submission status: Accepted

Solution code:
import sys
from itertools import accumulate

read = sys.stdin.read

N, *P = map(int, read().split())

p = accumulate(P, min)
print(sum(i <= j for i, j in zip(P, p)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
count = 0
min_num = N
for c in input().split():
    p = int(c)
    min_num = min(min_num, p)
    if min_num == p:
        count += 1
print(count)

Submission status: Accepted

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

count = 1
a =P[0]
for i in range(1,N):
  if a>=P[i]:
    count +=1
    a = P[i]
print(count)

Submission status: Accepted

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

value = 10 ** 9
ans = 0
for v in P:
    if v < value:
        ans += 1
        value = v
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
P = list(map(int, input().split()))
ans=1
if N!=1:
    M=P[0]
    for i in range(1,N,1):
        M=min(P[i],M)
        if P[i] ==M:
            ans+=1
print(ans)

Submission status: Accepted

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


def solve(N: int, P: "List[int]"):

    result = 1
    min_num = P[0]
    for i in range(N):
        if P[i] < min_num:
            result += 1
            min_num = P[i]
        else:
            pass
    print(result)

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

i = 0
j = 0
a = 10**6
for i in range(i,n):
  a = min(a,li[i])
  if a == li[i]:
    j = j + 1

print(j)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

j = 1
temp = p_list[0]
for i in range(1,N):
  if temp >= p_list[i]:
    j += 1
    temp = p_list[i]

print(j)

Submission status: Accepted

Solution code:
n, *p = map( int, open(0).read().split())
 
cnt = 0
min_val = 1000000
for i in range( len( p )):
  if p[i] < min_val:
    cnt += 1
    min_val = p[i]

print( cnt )

Submission status: Accepted

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

Submission status: Accepted

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

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):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Submission status: Accepted

Solution code:
_,p=open(0)
m=9e9
c=0
for p in map(int,p.split()):
 if p<m:c+=1;m=p
print(c)

Submission status: Accepted

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

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


print(ct)

Submission status: Accepted

Solution code:
def main():
    import sys
    N = int(input())
    input_2 = sys.stdin.readline
    P_list = list(map(int,input_2().split()))
    i_num = 0
    min_P = P_list[0]
    for p in P_list:
        if p <= min_P:
            min_P = p
            i_num += 1
    print(i_num)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
ray = [int(i) for i in input().split()]
ans = 1
min = ray[0]

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

Submission status: Accepted

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

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

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

print(cnt)

Submission status: Accepted

Solution code:
#C - Low Elements
import numpy as np
N = int(input())
P = np.array(list(map(int, input().split())))
min=P[0]
ans=1
for i in range(1,N):
    if min > P[i]:
        min = P[i]
        ans = ans +1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
p_list  = list(map(int,input().strip().split(" ")))

ans = 1
mi = p_list[0]

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

Submission status: Accepted

Solution code:
N = int(input())
P_lis = list(map(int, input().split()))
 
dummy = 2*10**5
answer = 0
 
for p in P_lis:
  if p <= dummy:
    answer += 1
    dummy = p
print(answer)

Submission status: Accepted

Solution code:
N = int(input())
P = list(map(int, input().split()))
cnt = 0
max = 2*10**5
for a in P:
    if a <=max:
        #print(a)
        cnt += 1
    max = min(max,a)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

j = 1
temp = p_list[0]
for i in range(1,N):
  if temp >= p_list[i]:
    j += 1
    temp = min(temp,p_list[i])

print(j)

Submission status: Accepted

Solution code:
_,p=open(0)
m=9e9
c=0
for p in map(int,p.split()):c+=p<m;m=min(m,p)
print(c)

Submission status: Accepted

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


def solve(N: int, P: "List[int]"):
    count=0
    mi=P[0]
    for i in range(1,N+1):
        if i==1:
            count+=1
            #print(i)
        else:
            if min(mi,P[i-1])==P[i-1]:
                count+=1
                mi=P[i-1]
                #print(i)
    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 = list(map(int, input().split()))
ans = 0
min_ = li[0]
for i in range(len(li)):
  if li[i] <= min_:
    ans += 1
    min_ = li[i]
print(ans)

Submission status: Accepted

Solution code:
_,p=open(0)
m=10**18
c=0
for p in map(int,p.split()):
    c+=p<m
    m=min(m,p)
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
mini = n +1
for _ in lst:
    if mini > _:
        mini = _
        i += 1
print(i)

Submission status: Accepted

Solution code:

N = int(input())
P = map(int, input().split())
stack = []
size = 0
for p in P:
    if not stack or stack[-1] > p:
        stack.append(p)
        size += 1
print(size)

Submission status: Accepted

Solution code:
import bisect
import numpy as np

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


    ans = 1
    f = P[0]

    for i in range(1, N):
        f_o = P[i]
        if f >= f_o:
            ans+=1
            f = f_o
    print(ans)
    return 0


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
minimum = 2 * 10 ** 5 + 1
for p in P:
    if p < minimum:
        count += 1
        minimum = p
print(count)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    P_list = list(map(int,input().split()))
    i_num = 0
    min_P = P_list[0]
    for p in P_list:
        if p <= min_P:
            min_P = p
            i_num += 1
    print(i_num)

if __name__ == "__main__":
    main()

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):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

dummy = 2*10**5
answer = 0

for p in P:
  if p <= dummy:
    answer += 1
    dummy = p

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
P_list = list(map(int,input().split()))
i_num = 0
min_P = P_list[0]
for p in P_list:
    if p <= min_P:
        min_P = p
        i_num += 1
print(i_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__=="__main__":
    n = int(input())
    args = input().split()
    p = []
    for i in range(len(args)):
        p.append(int(args[i]))

    cnt = 1
    p_pre = [p[0]]
    min_p_pre = p[0]
    for i in range(1,len(args)):
        p_pre.append(p[i])
        min_p_pre = min(min_p_pre, p[i])
        if p[i] == min_p_pre:
            cnt += 1

    print(cnt)

Submission status: Accepted

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

ans = 0
min = P[0]
for i in P:
  if min >= i:
    min = i
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
v = P[0]
for i in P:
    if i <= v:
        ans += 1
        v = i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

l = list(map(int,input().split()))
#print(l)

ans = 0
min_ = 999999
for i in l:
    if i <= min_:
        min_ = i
        ans += 1

print(ans)

Submission status: Accepted

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

m = []
mm = 10**8
for i in range(n):
    mm = min(mm,pl[i])
    m.append(mm)

res = 0
for i in range(n):
    if pl[i]==m[i]:
        res += 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


for index, i in enumerate(A):
    if index == 0:
        ans += 1
        small = i


    elif small >= i:
        ans += 1
        small = i      

print(ans)

Submission status: Accepted

Solution code:
class FenwickTree:
    """FenwickTree (Binary Indexed Tree, 0-index)

    Queries:
        1. add(i, val): add val to i-th value
        2. sum(n): sum(bit[0] + ... + bit[n-1])

    complexity: O(log n)

    See: http://hos.ac/slides/20140319_bit.pdf
    """

    def __init__(self, a_list):
        self.N = len(a_list)
        self.bit = a_list[:]
        for _ in range(self.N, 1 << (self.N - 1).bit_length()):
            self.bit.append(0)
        for i in range(self.N-1):
            self.bit[i | (i+1)] += self.bit[i]

    def add(self, i, val):
        while i < self.N:
            self.bit[i] += val
            i |= i + 1

    def sum(self, n):
        ret = 0
        while n >= 0:
            ret += self.bit[n]
            n = (n & (n + 1)) - 1
        return ret

    def query(self, low, high):
        return self.sum(high) - self.sum(low)


N = int(input())
P = [int(x) for x in input().split()]
P_idx = [(x, i) for i, x in enumerate(P)]
P_idx.sort()
fwt = FenwickTree([0] * N)
ans = 0
for x, idx in reversed(P_idx):
    if fwt.sum(idx) == idx:
        ans += 1
    fwt.add(idx, 1)
print(ans)

Submission status: Accepted

Solution code:
n = input()
N = int(n)
P = []
counter = 0
input_string = input()
P = input_string.split()

for i in range(int(N)):
    for j in range(N):
        if N == int(P[i]):
            counter = counter + 1
            if N != 1:
                N = N - 1
                break
            else: 
                break
        elif N < int(P[i]):
            break
        else:
            if N != 1:
                N = N - 1   

print(counter)

Submission status: Accepted

Solution code:
N=int(input())
P=list(map(int,input().split()))
m=2*10**5
a=0
for p in P:
    if p<=m:
        a+=1
    m=min(m,p)
print(a)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc152/tasks/abc152_c
# -*- coding: utf-8 -*-
N = int(input())
P = input().split()
T = []
L =0
T.insert(0,int(P[0]))
P[0] = int(P[0])
for i in  range(1,len(P)):
  P[i] = int(P[i])
  if T[-1]>=P[i]:
    L =+ 1
    if T[-1]>P[i]:
      T.append(P[i])
print(len(T))

Submission status: Accepted

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


cut = N
check =0
min = N

for i in range(1,N+1):
    
    if List[i-1]<=min:
        min = List[i-1]
        
    else:
        cut -=1

    




print(cut)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    a = list(map(int, r.split()))
    #a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    res = 1
    bk = a[0]
    for i in range(1,n):
        if bk >= a[i]:
            bk = a[i]
            res += 1
    print(res)


#    b = [0]*n
#    for i in range(n):
#        b[a[i]-1] = i

#    res = 0
#    mem = b[0]
#    for i in range(1,n):
#        if mem <= b[i]:
#            print(b[i])
##            mem = b[i]
#        else:
#            res += 1
#    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

minValue = 2*(10**5)
result = 0
for element in PN:
    if minValue >= element:
        minValue = element
        result += 1
print(result)

Submission status: Accepted

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

l = [int(i) for i in tl]

mn = n

count = 0
mn_i = 0
for i in range(len(l)):
    if l[i] > mn:
        continue

    sl = l[mn_i:i+1]
    mn = min(sl)
    mn_i = i
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

ok = 1
minp = [p[0]]

for i in range(1,n):
    if p[i] < minp[i-1]:
        minp.append(p[i])
        ok = ok + 1
    else:
        minp.append(minp[i-1])

print(ok)

Submission status: Accepted

Solution code:
n = int(input())
ps = list(map(int, input().split()))
fps = [ps[0]]
for i in range(1,n):
  if fps[len(fps)-1] > ps[i]:
    fps.append(ps[i])
print(len(fps))

Submission status: Accepted

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

min_val = P[0]
counter = 0
for i in range(n):
  min_val = min(P[i], min_val)
  if min_val == P[i]:
    counter += 1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    lists = list(map(int, input().split(' ')))
    min_i = (2 * 10) ** 5 + 1
    cnt = 0
    for item in lists:
        if min_i >= item:
            min_i = item
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ps3 = p[0]

ans = 0
for i,name in enumerate(p):
    if name <= ps3:
        ans += 1
    ps3 = min(ps3, name)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
min_v = P[0]

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

print (ans)

Submission status: Accepted

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

Submission status: Accepted

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

'''
選んだ数字(iで場所指定)より、左の数字が全て大きい。
'''
c = 0
MIN = p[0]
for i in range(n):
    if p[i] <= MIN:
        c += 1
        MIN = p[i]

print(c)

Submission status: Accepted

Solution code:
def acinput():
    return list(map(int, input().split(" ")))

N=int(input())
P=acinput()

minv=10**6

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

print(count)

Submission status: Accepted

Solution code:
n = input()
N = int(n)
P = []
counter = 0
input_string = input()
P = input_string.split()

for i in range(int(N)):
    for j in range(N):
        if N == int(P[i]):
            counter = counter + 1
            if N != 1:
                N = N - 1
                break
            else: 
                break
        elif N < int(P[i]):
            break
        else:
            if N != 1:
                N = N - 1   

print(counter)

Submission status: Accepted

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

min = i[0]
count = 1

for n in range(N-1):
    if min >= i[n+1]:
        min = i[n+1]
        count +=1
    else: pass

print(count)

Submission status: Accepted

Solution code:
N=int(input())
P=[int(i) for i in input().split()]
x=P[0]
a=1
if N==1:
    print(a)
else:
    for i in range(1,N):
        if x>P[i]:
            x=P[i]
            a+=1
    print(a)

Submission status: Accepted

Solution code:
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def minL():
  ml=[NS[0]]
  for i in range(1,N):
     ml+=[min(ml[i-1],NS[i])]
  return ml  

MINL=minL()
def exist():
    s=0
    for i in range(N):
      if MINL[i]>=NS[i]:
         s+=1
    return s
if __name__=='__main__':
   print(exist())

Submission status: Accepted

Solution code:
N, = map(int, input().split())
xs = map(int, input().split())
r = N+1
c=0
for x in xs:
    if x<r:
        c += 1
    r = min(r,x)
print(c)

Submission status: Accepted

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

for i in range(n):  
    if p[i] > min:
        cnt = cnt - 1
    else:
        min = p[i]
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
l1=[]
c=0
l1.append(l[0])
for i in range(1,n):
  l1.append(min(l1[i-1],l[i]))
for i in range(n):
  if(l[i]==l1[i]):
    c+=1
print(c)

Submission status: Accepted

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

count = N
m = 10**9

for i in range(N):
    if m != max(m,P[i]):
        count -= 1
    m = min(m,P[i])

print(count)