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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
# import numpy as np


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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
n = int(input())
lis = list(map(int,input().split()))
count = 0
mi = 0
for i,l in enumerate(lis):
    if i == 0:
        mi = l
        count += 1
    else:
        if l < mi:
            mi = l
        if mi >= l:
            count += 1
print(count)

Submission status: Accepted

Solution code:
import numpy as np

#a, b = map(int, input().split())
N = int(input())

#map(int, input().split())

# def bubble_sort(lst):
#     cnt = 0
#     for i in range(len(lst)-1):
#         for j in range(len(lst)-1, i, -1):
#             if lst[j-1] > lst[j]:
#                 tmp = lst[j]
#                 lst[j] = lst[j-1]
#                 lst[j-1] = tmp
#                 cnt += 1
#     return cnt

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

cnt = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
P = [int(x) for x in input().split(" ")]
mx = P[0]
ans = 1
for i in range(1,n):
    if mx > P[i]:
        ans += 1
        mx = P[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
mini = p[0]
flag = 0
cnt = 1
for i in range(1, len(p)):
  if(flag == 1):
    if(mini >= p[i]):
      mini = p[i]
      cnt += 1
  if(flag == 0):
    if(p[i-1] >= p[i]):
      mini = p[i]
      cnt += 1
    else:
      flag = 1

print(cnt)

Submission status: Accepted

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

cnt = 1
mi = p[0]

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


print(cnt)

Submission status: Accepted

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

for i in range(N):
    if min > P[i]:
        min = P[i]

    if min >= P[i]:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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


ans = 1
min_num = p[0]

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

print(ans)

Submission status: Accepted

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

def init_min(init_min_val):
    #set_val
    for i in range(N):
        seg_min[i+num_min-1]=init_min_val[i]    
    #built
    for i in range(num_min-2,-1,-1) :
        seg_min[i]=min(seg_min[2*i+1],seg_min[2*i+2]) 
    
def update_min(k,x):
    k += num_min-1
    seg_min[k] = x
    while k:
        k = (k-1)//2
        seg_min[k] = min(seg_min[k*2+1],seg_min[k*2+2])
    
def query_min(p,q):
    if q<=p:
        return ide_ele_min
    p += num_min-1
    q += num_min-2
    res=ide_ele_min
    while q-p>1:
        if p&1 == 0:
            res = min(res,seg_min[p])
        if q&1 == 1:
            res = min(res,seg_min[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = min(res,seg_min[p])
    else:
        res = min(min(res,seg_min[p]),seg_min[q])
    return res

#####単位元######
ide_ele_min = 10**10

#num_min:n以上の最小の2のべき乗
num_min =2**(N-1).bit_length()
seg_min=[ide_ele_min]*2*num_min
init_min(P)

answer = 1

for i in range(1, N):
    MIN = query_min(0, i)
    if MIN > P[i]:
        answer += 1

print(answer)

Submission status: Accepted

Solution code:
DEBUG = False

def dprint(*args):
    if DEBUG:
        print(*args)

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

num = 1
num_min = p.pop(0)
dprint(n, num_min, p)

for i in p:
  if i < num_min:
    num_min = i
    num += 1
  dprint(num, num_min)
  if i == 1:
    break

print(num)

Submission status: Accepted

Solution code:
import sys

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

count = 0
min = P[0]
for i in range(N):
    if P[i] <= min:
        min = P[i]
        count += 1
    """
    else:
        for j in range(i+1):
            if P[i] > P[j]:
                break
        else:
            count += 1
    """
print(count)

Submission status: Accepted

Solution code:
n=int(input())
P=list(map(int,input().split()))
x=float("inf")
ans = 0
for i in range(n):
  if x > P[i]:
    ans += 1
    x = P[i]
print(ans)

Submission status: Accepted

Solution code:
N=int(input())

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

ans=None

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

ans=count

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input().split()
n=int(s[0])
s=input().split()
mini=10000000
out=0
for i in range(n):
    if mini>=int(s[i]):
        mini=int(s[i])
        out+=1
print(out)

Submission status: Accepted

Solution code:
max = int(input())
orgList = list(map(int, input().split()))
min = 999999999999

result = 0;
for i in range(max):
    assertNo = orgList[i]
    if min > orgList[i]-1:
        min = orgList[i]

    if min >= assertNo:
        result+= 1

print(result)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
f={}
x=1
   
ans=n
min=l[0]
c=0
for i in range(n):
    if l[i]<=min:
        #ans+=1
        min=l[i]
    else:
        c+=1
        #print(l[i])
        
    #print(min)
    
print(ans-c)

Submission status: Accepted

Solution code:
import heapq

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

a = []
heapq.heapify(a)
ans = 0
for i in p_L:
    heapq.heappush(a, i)
    min_num =  a[0]
    #print(max_num,i)
    if i == min_num:
        ans += 1

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
min = float('inf')

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


i_list = [False] * N

min_tmp = p_list[0]

for i in range(N):
    if p_list[i] > min_tmp:
        i_list[i] = False

    else:
        min_tmp = p_list[i]
        i_list[i] = True


ans = i_list.count(True)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
pi=[]
for i in map(int,input().split()):
    pi.append(i)
#print(pi)
pmin=[]
pmin.append(pi[0])
for i in range(n-1):
    if pmin[i]>pi[i+1]:
        pmin.append(pi[i+1])
    else:
        pmin.append(pmin[i])
#print(pmin)

icnt=0
for i in range(n):
    if pi[i]<=pmin[i]:
        icnt=icnt+1
print(icnt)

Submission status: Accepted

Solution code:
N = int(input())
P = input().split()
count = 0
cur_min = int(P[0])

for i in range(N):
  if cur_min >= int(P[i]):
    cur_min = int(P[i])
    count += 1
print(count)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1
min_p = P[0]
for i in range(1, len(P)):
  if P[i] < min_p:
    cnt += 1
    min_p = P[i]

print(cnt)

Submission status: Accepted

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

ans = [1]
mini = P[0] 
for i in range(1, len(P)):
    if mini > P[i]:
        mini = P[i]
        ans.append(i+1)

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

c = 0
m = p[0]
for i in range(n):
    m = min(m, p[i])
    if m >= p[i]:
        c += 1
print(c)

Submission status: Accepted

Solution code:
import sys
sysinput = sys.stdin.readline

N = int(sysinput())
P = list(map(int, sysinput().split()))
memo_mini = N
i_count = 0
for i in range(0, N):
  if memo_mini >= P[i]:
      i_count +=1
      memo_mini = P[i]
  else:
    pass
  
print(i_count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    P = list(map(int, input().split()))

    p1 = [0] + P
    p2 = [0, P[0]]
    for p in P[1:]:
        p2.append(min(p2[-1], p))
    ans = 0
    for i in p1[1:]:
        if p1[i] <= p2[i]:
            ans += 1
    print(ans)


main()

Submission status: Accepted

Solution code:
N = int(input())

P =list(map(int, input().split()))
count = 1
ini = P[0]

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

print(count)

Submission status: Accepted

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

ret = 0
c_min = 2e5

for i in p:
    if c_min >= i:
        c_min = i
        ret+=1
print(ret)

Submission status: Accepted

Solution code:
# ABC 152 C

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

res = 0
minP = 10 ** 9

for i in range(N):
    if P[i] <= minP:
        res += 1
        minP = P[i]
    else:
        continue

print(res)

Submission status: Accepted

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

for i in range(n) :
	p[i] = int(p[i]);

dp = [0]*n;
flg = [1]*n;
comp = n+1;

for i in range(1,n) :
	if p[i-1] < p[i] and p[i-1] < comp :
		comp = p[i-1];
	if p[i] > comp :
		flg[i] = 0;


print(sum(flg));

Submission status: Accepted

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

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

ans = 0
max = N + 1
for p in P:
    if max > p:
        max = p
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    p = LI()
    a = inf
    ans = 0
    for i in range(n):
        ans += a >= p[i]
        a= min(a, p[i])
    print(ans)
    return


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
per = [0] + [int(i) for i in input().split()]
res = 0
min_per = per[1]
for i in range(1, N+1):
  min_per = min(min_per, per[i])
  flag = True
  if per[i] > min_per: 
    pass
  else: 
    res += 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())
P = [int(i) for i in input().split()]
mini = P[0]
ans = 0
for i in P:
    if i <= mini:
        ans += 1
        mini = i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ns = list(map(int, input().split()))
min_n = float("inf")
count = 0
for i in ns:
    if i < min_n:
        count += 1
        min_n = i
    if i == 1:
        break
print(count)

Submission status: Accepted

Solution code:
n = int(input())
all_number = input().split()
count = 0
lowest = int(all_number[0])
for i in range(n):
  if(int(all_number[i]) <= lowest):
    count = count + 1
    lowest = int(all_number[i])
print(count)

Submission status: Accepted

Solution code:

# C
n = int(input())
p = [int(i)for i in input().split()]

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    P = list(map(int,input().split()))
    min_val = 2*10e5
    count = 1
    for i in range(1,N):
        if min_val > P[i-1]:
            min_val = P[i-1]
        if P[i] <= min_val:
            count += 1
    print(count)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
P_list = list(map(int, input().split()))
cnt = 0
min_num = P_list[0]
for P in P_list:
    if min_num >= P:
        cnt += 1
        min_num = P
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]:
        num = P[i]
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

INF = 99999999

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

mins = [INF] * N

ans = 1
mins[0] = P[0]

for i in range(1,N):

    if (mins[i-1] > P[i]):
        ans += 1
        mins[i] = P[i]
#        print("i:" + str(i));
#        print(mins);
    else:
        mins[i] = mins[i-1]

print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
pl = list(map(int, readline().split()))

min_ = pl[0]
ans = 0
for x in pl:
    if x <= min_:
        ans += 1
    if x < min_:
        min_ = x

print(ans)

Submission status: Accepted

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

c = [True for i in range(n)]
target = p[0]
for i in range(1,n):
  if p[i]>target:
      c[i] = False
  else:
    target = p[i]
print(sum(c))

Submission status: Accepted

Solution code:
import sys

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

num =0
mi = ll[0]
for i in range(N):
  a = ll[i]
  if mi >= a:
    mi = a
    num += 1

print(num)

Submission status: Accepted

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

ans = 0
min_val = Ps[0]
for i,p in enumerate(Ps):
  if p<=min_val:
    ans += 1
    min_val = p
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

N = int(input().strip())
P = list(map(int, input().strip().split()))
ans = 0
min = 1e10
for i in range(N):
  #Q = copy.copy(P[0:i+1])
  #Q.sort()
  #print(P)
  #print(Q)
  #if Q[0] >= P[i]:
  #  ans += 1
  if P[i] < min:
    min = P[i]
    ans += 1
  """
  flag = True
  for j in range(0, i):
    if P[i] > P[j]:
      flag = False
      break
  if flag:
    ans += 1
  """
  
print(ans)

Submission status: Accepted

Solution code:
def Convert(string): 
    li = list(map(int, string.split(" "))) 
    return li 

N = input().split()
L = Convert(input())
Min = L[0]
Sum = 0

for i in L:
    if i <= Min:
        Sum += 1
        Min = i
        

print(Sum)

Submission status: Accepted

Solution code:
import sys
N = int(input())
A = list(map(int, input().split())) 
count=0
max=sys.maxsize

for i in A:
    if i<=max:
        count+=1
        max=i
        
print(count)

Submission status: Accepted

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

res = 1

minP = P[0]
for i in range(len(P)-1):
    if minP > P[i+1]:
        minP = P[i+1]
        res += 1

print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

max_v = p[0]  # 現在注目している値より前に出てきた値の中で一番大きな値
min_v = p[0]
ans = 1
for i in range(1, len(p)):
    # print(f"i: {i}  p[i]: {p[i]}  max_v: {max_v}  min_v: {min_v}  ans: {ans}")
    if p[i] <= max_v and p[i] <= min_v:
        ans += 1
        # print("Plus ONE")
    if p[i] > max_v:
        max_v = p[i]
    if p[i] < min_v:
        min_v = p[i]
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
dummy = list(map(int, input().split(" ")))
N = dummy[0]

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

out = 0
min = N + 1
for a in range(N):
    if(P[a] <= min):
        min = P[a]
        out += 1

#print(P)
print(out)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1
p_min = P[0]

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

print(cnt)

Submission status: Accepted

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

a = P[0]
x = []
x.append(P[0])
for i in range(1,len(P)):
    if a >= P[i]:
        x.append(P[i])
        a = P[i]
print(len(x))

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
N = int(input())
P = str(input()).split()
PP = []
# S = [[0 for i in range(W)] for j in range(H)]
val = 0

for i in range(N):
  PP.append(int(P[i]))

MIN = PP[0]

for i in range(N):
  #print(max(PP[:i+1]))
  #print(PP[i])
  MIN = min(MIN, PP[i])
  if(MIN>=PP[i]):
    val += 1

print(val)

Submission status: Accepted

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

ll = []
ll.append(l[0])

for i in range(len(l)-1):
  if l[i] > l[i+1]:
    ll.append(min(l[i+1], ll[i]))
  else:
    ll.append(ll[i])

count = 0
for i in range(len(ll)):
  if l[i] <= ll[i]:
    count+=1

print(count)

Submission status: Accepted

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

x=a[0]

for i in range(0,n):
  if x >= a[i]:
#    print(a[i])
    x=a[i]
    c+=1
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret




def main():
    # n = int(input())
    # a = list(map(int, input().split()))
    
    # v = a[0]
    # for i in range(1, n):
    #     v = lcm(v, a[i])
    
    # ans = 0
    # v %= MOD
    # for i in range(n):
    #     ans += v * modinv(a[i], MOD) % MOD
    #     ans %= MOD
    # print(ans)
    # n = int(input())
    # d = defaultdict(int)
    # for i in range(1,n+1):
    #     if i < 10:
    #         d[(i, i)] += 1
    #     else:
    #         d[(int(str(i)[-1]), int(str(i)[0]))] += 1
    
    # ans = 0
    # for i in range(1, n):
    #     if i < 10:
    #         ans +=d[(i, i)]
    #     else:
    #         if int(str(i)[-1]) == int(str(i)[0]):
    #             ans += d[(int(str(i)[0]), int(str(i)[-1]))]
    #         else:
    #             ans += d[(int(str(i)[0]), int(str(i)[-1]))]
    # print(ans)

            

    # ans = 0
    # for i in range(1,n+1):
    #     # if set(str(i)) == 1:
    #     #     continue
    #     ss = str(i)[::-1]
    #     if int(ss) <= n and str(ss)[0] != "0":
    #         ans += 1
    #         print(i,str(i)[::-1])
    # print(ans)

    # for i in range(1, 10):
    #     t = 0
    #     s = ""
    #     for j in range(6):
    #         s += str(i)
    #         if int(s) > n:
    #             break
    #         t += 1
    #     if t == 1:
    #         continue
    #     k = 1
    #     for j in range(1, t + 1):
    #         k*=j
    #     ans += k
    #     # print(k)
    # print(ans)   


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




    


if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = 0
min =99999999

for i in range(len(k)):
  if min > k[i]:
    min= k[i]
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
min = N

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

for i in range(N):
    if data >= li[i]:
        ans += 1
        data = li[i]

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = 0
    P = [int(_) for _ in input().split()]
    for i in range(N):
        if i == 0:
            x = P[0]
        if P[i] <= x:
            ans += 1
            x = P[i]
    print(ans)
main()

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
m = 2*10**5
cnt=0
if n == 1:
  print(1)
else:
  for i in range(n-1):
    if m > p[i]:
      m = p[i]
    if m > p[i+1]:
      #print(p[i+1])
      cnt+=1
  print(cnt+1)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
minimum = 10 ** 6

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

print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離

N = iin()
a = iln()
mi = a[0]
ans = 1
for i in range(1, N):
    if mi >= a[i]:
        ans += 1
    mi = min(mi, a[i])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
min_num = float("inf")
for i in range(N):
    if min_num >= P[i]:
        ans += 1
        min_num = P[i]


print(ans)

Submission status: Accepted

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

for i in range(n):
  if p[i] <= sta:
    li[i]=1
    sta = p[i]

print(sum(li))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
li=list(map(int,input().split()))
ans=0
tmp=li[0]

for i in range(n):
    if li[i]>tmp:
        ans+=1
    else:
        tmp=li[i]

print(n-ans)

Submission status: Accepted

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

ans_r=0
min_num=P[0]
for p in range(0, N):
  if (min_num > P[p]):
    min_num=P[p]
  if (min_num < P[p]):
    ans_r += 1
print (N-ans_r)