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:
n = int(input())
p = list(map(int,input().split()))
d = p[:]
s = 1
p.remove(n)
d = n-2 if d[0] not in p else n-1
for i in range(d,0,-1):
  if p[i-1] > p[i]:
    s+=1
if d==n-2:
  s+=1
print(s)

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)

Submission status: Runtime Error

Solution code:
N = int(input())
P = [int(x) for x in input().split()]
count = 0
check = 0
for i in range(N):
    check = 0
    for j in range(i):
        if P[i] > P[j]:
            check = 1
            break
    if check == 0:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N, value;
    vector<int> P(N);
    
    cin >> N;
    int minimum = N;
    int ans =0;
    for (int i =0; i < N; i++){
        cin >> P.at(i);
    }

    for (int i =0; i < N; i++){
        value = P.at(i);
        if (value <= minimum){
            ans += 1;
            minimum = value;
        }
    }

    cout << ans << endl;
    
    
}

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

cnt=0

import numpy as np

P=np.array(P)

max_val=P[0]

cnt=1

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

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

print(cnt)

Submission status: Runtime Error

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

temp = []

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

print(str(len(temp))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main(void){
    int N;
    cin >> N;
    std::vector<int> P(N);
    for (int i=0;i<N;i++){
        cin >> P.at(i);
    }
    int ans =0;
    int check;
    for (int i=0;i<N;i++){
        check = 0;
        for (int j=0;j<i;j++){
            //cout <<P.at(i)<<"VS"<<P.at(j)<<endl;
            if(P.at(i)>P.at(j)){
                check = 1 ;
            }
        }
        
        if (check == 0){
            ans ++;
        }
        //cout<<ans<<endl;
    }
cout << ans<<endl;
return 0;

}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

print(c)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
count = 0
a = 200001

n = int(input())
for i in range(n):
    b = int(input())
    if(a >= b):
        a = b
        count += 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

m = p.index(1)
f = p[m+1:]
s = list(range(1, n+1))
l = list(set(s) - set(f))
l.sort()
l.remove(1)
ans = 1
if n == 1:
    print(1)
    exit()
for i in p[m::-1]:
    if l[0] == i:
        l.remove(l[0])
        ans += 1

print(ans)

Submission status: Runtime Error

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

for i in range(len(P)):
  if min(P[:i+1]) != P[i]:
    return i
  return len(P)

Submission status: Runtime Error

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

for i in range (1,N):
  if P[i] < p[i-1]:
    num +=1
print(nun)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
l=map(int, input().split())
# n=5
# l=[4,2,5,1,3]
count=0
for i in range(1,len(l)+1):
#     print(l[:i])
#     print(l[i-1])
    if min(l[:i])==l[i-1]:
        count+=1
    
    
    
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input()

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

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

Submission status: Runtime Error

Solution code:
 N = int(input())
 P = list(map(int, input().split()))
 n = N
 for i in range(N):
   for j in range(i):
     if P[i] > P[j]:
       n -= 1
       break
     else:
        pass
print(n)