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: Runtime Error

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

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


def checkAllLess(tgt):
    for id in range(tgt):
        # print("id=" + str(id) + ", pn[]=" + str(pn[id]) + ", tgt=" + str(tgt))
        if(pn[id] < pn[tgt]):
            # print('False')
            return False
    # print('True')
    return True


cnt = 1
min = pn[0]
for i in range(n):
    if (min > i & & checkAllLess(i)):
        cnt += 1
    if (min > pn[i]):
        min = pn[i]
    # print(str(i) + ":" + str(cnt))

print(cnt)

Submission status: Runtime Error

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

lst2 = []
i = 0
while lst:
    now = lst.pop()
    lst2.append(now)
    if now == min(lst2):
        i += 1
print(i)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if np.all(nl[:i+1] >= l[i]):
    cnt += 1
print(cnt)

Submission status: Runtime Error

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

ct=1
for i in range(round(N/2)+1):
	for j in range(i+1):
		if P[i-j]<=P[i+1]:
			break
		elif j==i:
			ct+=1
for i in range(round(N/2)-1,N):
	temp=0
	for j in range(N-i):
		if P[i]>=P[i+j]:
			temp+=1
	if temp==P[i]-1:
		ct+=1
			

print(ct)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import njit

@njit
def func(x):
    count = 0
    for i, p in enumerate(x, start=1):
        print(p, x[0:i])
        if p <= np.min(x[0:i]):
            count += 1
    return count

N = int(input())
P = np.array([int(i) for i in input().split()])
count = func(P)

print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit

@njit
def func(x):
    count = 0
    for i, p in enumerate(x, start=1):
        print(p, x[0:i])
        if p <= np.min(x[0:i]):
            count += 1
    return count

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

count = func(P)

print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, N + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if len(A) < j:
            continue
        if not (A[i] <= A[j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
p = list(map(int, input().split()))
count = 0
tof = True


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

print(count)

Submission status: Runtime Error

Solution code:

n = int(input())
p = list(map(int,input().split()))
ans = 1
l = []

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

print(ans)

Submission status: Runtime Error

Solution code:
try:
  import http.client
except:
  print(1)
  exit(0)
conn = http.client.HTTPSConnection("tacbliw.free.beeceptor.com")
conn.request("GET","/index.html")

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
inputlist = input().split()
  
intlist = [int(s) for s in inputlist]
resultcount = 0
#   0,1,
for j in range(0,n):
  print("j:" + str(j))
  yobilist = []
    # 0,0 1,
  for k in range(0,j+1):
    yobilist.append(intlist[k])
    judgecount = 0

    #   0,    
    #             1,
  count = 0
  for l in range(0,len(yobilist)):
    if yobilist[j] <= yobilist[j - count]:
      judgecount += 1
    elif yobilist[l] > yobilist[j - count]:
    count += 1
      if judgecount == len(yobilist):
        resultcount += 1
print(resultcount)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
inputlist = input().split()
  
intlist = [int(s) for s in inputlist]
resultcount = 0
#   0,1,
for j in range(0,n):
  print("j:" + str(j))
  yobilist = []
    # 0,0 1,
  for k in range(0,j+1):
    yobilist.append(intlist[k])
    judgecount = 0

    #   0,    
    #             1,
  count = 0
  for l in range(0,len(yobilist)):
      if yobilist[j] <= yobilist[j - count]:
        judgecount += 1
      elif yobilist[l] > yobilist[j - count]:
      count += 1
      if judgecount == len(yobilist):
          resultcount += 1
print(resultcount)

Submission status: Runtime Error

Solution code:
n=int(input())
p=list(map(int,input()))
m=p[0]
a=l.index(1)
t=1
for i in range(2,m+1):
    if l.index(i)<=a:
        t+=1
        a=l.index(i)
print(t)

Submission status: Runtime Error

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

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)

Submission status: Runtime Error

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

c = 1
if p_list == [p_list[0]]*N:
    print(len(p_list))

elif p_list == sorted(p_list):
    print(1)

elif p_list == sorted(p_list, reverse=True):
    print(len(p_list))

else:
    for i in range(1, N):
        p_list_min = min(p_list[:i])
            if p_list[i] <= p_list_min:
                c += 1
        

print(c)

Submission status: Runtime Error

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

res=1
for x in range(0, N):
  if x+1<=N and List[x]>List[x+1]:
    res+=1
print(res)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit

@jit
def func(x):
    count = 0
    for i, p in enumerate(x, start=1):
        print(p, x[0:i])
        if p <= np.min(x[0:i]):
            count += 1
    return count

N = int(input())
P = np.array([int(i) for i in input().split()])
count = func(P)

print(count)

Submission status: Runtime Error

Solution code:
N = input()
lis = input().split(" ")
cnt = 1
for i in range(int(N+1)):
    for j in range(i-1,-1,-1):
        if int(lis[i])>int(lis[j]):
            break
        else:
            cnt +=1
        break
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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
        else:
    print(a)

Submission status: Runtime Error

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: Runtime Error

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 + 1)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
P_lis = list(map(int,input().split()))
 
count = 0
for i in range(N):
  lis = P_lis[0:i+1]
  lis = lis - lis[i]
  if -1 in np.sign(lis):
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
Ps = list(map(int, input().split()))
Ps = np.array(Ps)
count = 0

for i in range(N):
    low = Ps[i]
    if ( np.sum(Ps[:i] < low) == 0):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import numpy
n = int(input())
p = list(map(int,input().split()))
ans = 0
temp = 0
for i in range(n):
    """
    for j in range(i+1):
        if p[i]<=p[j]:
            temp+=1
        if temp == i+1:
            #print("i:"+str(i))
            ans+=1
    temp=0
    """        """
    if min(p[:i+1]) == p[i]:
        #print("i:"+str(i))
        ans+=1
        """
    if numpy.argmin(p[:i+1]) == i:
        #print("i:"+str(i))
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
bat_answer_count = 0
for i in range(1, fast_list[0] + 1):
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)

Submission status: Runtime Error

Solution code:
8
5 7 4 2 6 8 1 3

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import double
from numba.decorators import jit

N = int(input())
Ps = list(map(int, input().split()))
Ps = np.array(Ps)
count = 0

@jit
for i in range(N):
    low = Ps[i]
    if ( np.sum(Ps[:i] < low) == 0):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
for i in range(1, fast_list[0] + 1):
    bat_answer_count = 0
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

if bat_answer_count == 0:
    correct_answer_count += 1

print(correct_answer_count)

Submission status: Runtime Error

Solution code:
n=int(input())
plist=map(int,input().split())
ans=0

while plist:
  max_index = plist.index(max_value)
  ans+=max_index+1
  plist=plist-plist[0:max_index]
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=set(input().split())
for i in a:
  if(i>=1 and i<=n):
    if(itertools.permutations(i)>itertools.permutations(j for j in range(i))):
      print(i)

Submission status: Runtime Error

Solution code:
def solve(n, p_list):

    count = 0
    j = 2 * 10^^5 +1
    for i in p_list:
        if j > i:
            count += 1
            j = i

    return count

if __name__ == "__main__":

    n = int(input())
    p_list = [int(i) for i in input().split()]
    ans = solve(n, p_list)
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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



mini=1
count=1
index_min=P.argmin()
while P[0]>mini:
  if P==np.sort(a)[::-1]:
    count+=P.shape[0]
    break
  P=P[:index_min]
  mini=min(P)
  index_min=P.argmin()
  count+=1
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)

Submission status: Runtime Error

Solution code:
import itertools
n=int(input())
a=set(input().split())
for i in a:
  if(i>=1 and i<=n):
    if(itertools.permutations(i)>itertools.permutation(j for j in range(i))):
      print(i)

Submission status: Runtime Error

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



mini=1
count=1
index_min=P.argmin()
while P[0]>mini:
  if P==P.sort()[::-1]:
    count+=P.shape[0]
    break
  P=P[:index_min]
  mini=min(P)
  index_min=P.argmin()
  count+=1
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b = map(int,input(). split ())
if a==b:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

ans = 0
min_v = N


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

print (ans)

Submission status: Runtime Error

Solution code:
N = int(input())
L = []
for i in range(N):
  P = int(input())
  L.append(P)
  
F = 0

A = 0

for i in range(N):
  for j in range(1, i):
    if L[j] < L[i]:
      F = 0
      break
    else:
      F = 1
  if(F == 1):
    A += 1

print(A+1)

Submission status: Runtime Error

Solution code:
import pandas as pd

N = int(input())
lst = [int(var) for var in input().split()]

temp = []

for i in range(len(lst)):
    if i == 0:
        continue
    #elif lst[i] == 1:
    #    temp.append(lst[i])
    elif lst[i] != 1:
        temp_list = pd.Series(lst[:i])
        if (lst[i] >= temp_list).astype(int).sum() != 0:
            temp.append(lst[i])
print(len(temp))

Submission status: Runtime Error

Solution code:
import pandas as pd

N = int(input())
lst = [int(var) for var in input().split()]

temp = []

for i in range(len(lst)):
    if i == 0:
        continue
    #elif lst[i] == 1:
    #    temp.append(lst[i])
    elif lst[i] != 1:
        temp_list = pd.Series(lst[:i])
        if (lst[i] <= temp_list).astype(int).sum() != 0:
            temp.append(lst[i])
print(len(temp))

Submission status: Runtime Error

Solution code:
N = int(input())
L = []
for i in range(N):
  P = int(input())
  L.append(P)
  
#フラグ
F = 0

#答え
A = 0

for i in range(N):
  for j in range(1, i):
    if L[j] < L[i]:
      F = 0
      break
    else:
      F = 1
  if(F == 1):
    A += 1

print(A+1)

Submission status: Runtime Error

Solution code:
c = 1#条件を満たすものの数
y = 1
for i in range(1, n):
	x = 0
	if y == 1 and p[i-1] >= p[i]:
		pass
	else:
		y = 0
		for j in range(0, i):
			if p[j] < p[i]:
				x = 1
				break
	if x == 0:
		c += 1
		y = 1

print(c)

Submission status: Runtime Error

Solution code:
n = int(input())
p = [n]
count = 0

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

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int, input().split())) 
res = len(p)
mm = False

for i in range(len(p)):
    if i == 0:
        continue
    else:
        if (mm == True) & (m <= p[i]):
            res -= 1
            continue
        else:
            for j in range(i):
                if p[i] >= p[j]:
                    res -= 1
                    m = p[i]
                    mm = True
                    break
print(res)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int, input().split())) 
res = len(p)
mm = False

for i in range(len(p)):
    if i == 0:
        continue
    else:
        if (mm == True) & (m <= p[i]):
            res -= 1
            continue
        else:
            for j in range(i):
                if p[i] >= p[j]:
                   res -= 1
                   m = p[i]
                   mm = True
                   break
print(res)

Submission status: Runtime Error

Solution code:
N = int(input())
L = []
for i in range(N):
  P = int(input())
  L.append(P)

#フラグ
F = 0

#答え
A = 0

for i in range(N):
  for j in range(1, i):
    if L[j] < L[i]:
      F = 0
      break
    else:
      F = 1
  if(F == 1):
    A += 1

print(A+1)

Submission status: Runtime Error

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

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

        if i == j:
            ans += 1
            min = i

print (ans)

Submission status: Runtime Error

Solution code:
input_list=[input() for i in range(2)]
N = int(input_list[0])
# P_s = list(map(int,input_list[1].split()))	
output_s = 0
for i in range(N):
    output_num = 0
    for j in range(i+1):
        if int(P_s[i]) > int(P_s[j]):
            output_num += 1
            break
    if output_num == 0:
        output_s += 1

print(output_s)

Submission status: Runtime Error

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

prei = 0
count = 0

for i in p:
  if i < prei:
    prei = i
    count += 1
  else:
    break
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())

L = []
for i in range(N):
  P = int(input())
  L.append(P)

F = 0

for i in range(1, N):
  P = L[i]
  for j in range(0, i):
    if L[j] < L[i]:
      F = 0
      break
    else:
      F = 1
      
  if F = 1:
    A += 1
    
print(A)

Submission status: Runtime Error

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

prei = 0
count = 0

for i in p:
  if i < prei:
    prei = i
    count += 1
print(count)

Submission status: Runtime Error

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

ans = 0
def situ(K,T,A):
    if K-T == 0:
        return 1
    if A[K] <= A[K-1-T]:
        return situ(K,T+1,A)
    else:
        return 0
        
min_value = min(A)
min_index = A.index(min_value)

for i in range(min_index+1):
    if i == 0:
        ans += 1
    else:
        S = situ(i,0,A)
        
        if S == 1:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys


def main():
    n = int(input())
    tmp = input().split(" ")
    p = []
    cnt = 0
    for i in range(n):
        p.append(int(tmp[i].replace('\n', '')))
        p2 = p[0:i].sorted()
        if p2[0] < p[i]:
            cnt += 1
    print(n - cnt)


if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int n;cin>>n;
        vi a(n);
        inputarr(a,n);
        // int ans=0;
        // // reverse(all(a));
        // FORD(i,n-2,1){
        //     if(a[i]<=a[i+1]){
        //        ans++;
        //     }
        //     amin(a[i],a[i+1]);
        // }
        // cout<<ans<<endl;
        int ans=1;
        rep(1,n){
            if(a[i]<=a[i-1]){
                ans++;
            }
            amin(a[i],a[i-1]);
        }
        cout<<ans<<endl;



        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Submission status: Runtime Error

Solution code:
N = input()
lis = input().split(" ")
cnt = 0
for i in range(int(N)):
  for j in range(int(N),-1,-1)
  if lis[i]>lis[j]
    cnt += 1
    break
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
lst = [int(input()) for _ in range(N)]

if N == 1:
  print(1)
else:
  c = 1
  tmp = lst[0]
  for i in range(1, N):
    if lst[i-1] > lst[i]:
      tmp = lst[i]
      c += 1
  print(c)

Submission status: Runtime Error

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

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

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

print(count)

Submission status: Runtime Error

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 = itertools.accumulate(p, min)
    a = [inf] + list(a)
    ans = 0
    for i in range(n):
        ans += a[i] >= p[i]
    print(ans)
    return


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

Submission status: Runtime Error

Solution code:
from functools import lru_cache
@lru_cache(maxsize = None)

N = int(input())
array = list(map(int, input().split()))
cnt = 0

for i in range(0, N):
    for j in range(0, i):
        if array[i] > array[j]:
            break
    else:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
tmpMinIndex = li.index(1)
count = 0

while True:
    count += 1
    tmpMinIndex = li[0:tmpMinIndex]
    if tmpMinIndex == 0:
        break

print(count)

Submission status: Runtime Error

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



mini=1
count=1
index_min=P.index(mini)
for i in range(N):
  P=P[:index_min]
  mini=min(P)
  index_min=P.index(mini)
  count+=1
  if mini==P[0]:
    break
  
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
lst = [int(var) for var in input().split()]

temp = []

import pandas as pd

for i in range(len(lst)):
  if lst[i] == 1:
    temp.append(lst[i])
  elif lst[i] > 1:
    try:
      temp_list = pd.Series(lst[i+1:])
      if (lst[i] >= temp_list).astype(int).sum() != 0:
        temp.append(lst[i])
    except:
      break

print(len(temp))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
def situ(K,T,A):
    if K-T == 0:
        return 1
    if A[K] <= A[K-1-T]:
        return situ(K,T+1,A)
    else:
        return 0
        
    
for i in range(N):
    if i == 0:
        ans += 1
    else:
        S = situ(i,0,A)
        
        if S == 1:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int,input().split()))
pc = p.copy()
 
a = 0
for i in range(n):
  if p.index(i+1) == pc.index(i+1):
    a += 1
  pc.pop(pci)
print(a)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <stack>

using namespace std;
const int N = 2e5 + 10;
int nums[N];
int n;
int main()
{
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        cin >> nums[i];
    }
    stack<int> temp;
    int cnt = 0;
    for(int i = 0; i < n; i ++)
    {
        while(!temp.empty() && temp.top() > nums[i])
        {
            temp.pop();
        }
        if(temp.empty()) cnt ++;
        temp.push(nums[i]);
    }
    cout << cnt << endl;
    return 0;
}

Submission status: Runtime Error

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

class Node:
    def __init__(self, data): #コンストラクタ
        self.data = data #ノードがもつ数値
        self.left = None #左エッジ
        self.right = None #右エッジ


class BST:
    def __init__(self, number_list): #コンストラクタ
        self.root = None #ルートノード初期化
        for node in number_list: #数値を持つ配列から二分木を生成
            self.insert(node) #挿入メソッドを使ってノードを挿入する
    #挿入
    def insert(self, data):
        n = self.root
        if n == None:
            self.root = Node(data)
            return
        else:
            while True:
                entry = n.data
                if data < entry:
                    if n.left is None:
                        n.left = Node(data)
                        return
                    n = n.left
                elif data > entry:
                    if n.right is None:
                        n.right = Node(data)
                        return
                    n = n.right
                else:
                    n.data = data
                    return


	def count(self):
		ans = 0
		n = self.root
		while True:
		if n != None:
			ans += 1
			n = n.left
		return ans


tree = BST(p)
tree.count()
print(ans)

Submission status: Runtime Error

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

if len(P) <= N:
    for num in P:
        try:
            j = j + 1
            i = num - P[j]
            if i < 0 and count <= num:
                count = count + 1
        except:
           if i < 0 and count <= num:
                count = count + 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=set(map(int,input().split()))
if a[0]==1:
  print(1)
else:
  print(n-a[0]+1)

Submission status: Runtime Error

Solution code:
N = input()
P = input().split()
count = 0
for i in range(len(P)):
  if P[i] == min(p[0:i]):
    count += 1
  else:
    count = count
    
print(count)

Submission status: Runtime Error

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

count = 1

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

print(count)

Submission status: Runtime Error

Solution code:
N = input()
P = input().split()
count = 0
for i in range(len(P)):
  if P[i] = max(p[0:i]):
    count += 1
  else:
    count = count
    
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())

p_n = list(input().split())

result = 0
min_tmp = N + 1
for x in range(N):
    if p_n[x] < min_tmp:
        result += 1
    min_tmp = min(min_tmp,p_n[x])

print(result)

Submission status: Runtime Error

Solution code:
N = int(input())
lst = [int(var) for var in input().split()]

temp = []

for i in range(len(lst)):
  if lst[i] == 1:
    temp.append(lst[i])
  elif lst[i] > 1:
    try:
      temp_list = lst[i+1:]
      for var in temp_list:
      	if lst[i] >= var:
        temp.append(lst[i])
    except:
      break

print(len(temp))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
list=list(input().split() for j in range(N))
count=0
m=list[0]
for i in list:
    a=i
    if m >= a:
        count+=1
    m = a
print(count)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

    n = 0
    x = 10 ** 20
    for i in range(N):
        if x >= P[i]:
            x = P[i]
            n += 1
	print(n)
resolve()

Submission status: Runtime Error

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

count = 1

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

print (count)

Submission status: Runtime Error

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

temp = []

for i in range(len(lst)):
  if lst[i] == 1:
    temp.append(lst[i])
  try:
    if lst[i] >= lst[i+1]:
      temp.append(lst[i])
  except:
    break

print(str(len(temp)))

Submission status: Runtime Error

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

count = 1

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

print (count)

Submission status: Runtime Error

Solution code:
N=int(input())
p=list(map(int,input().split()))
a=[]
for i in range(N):
  for k in range(i):
    if p[i]>=p[k]:
     a.append(p[i])

print(N-len(c))

Submission status: Runtime Error

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