solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
i=input;i();s=list(map(int,i().split()));ans=0;mi=10001;ma=0 for k in s:ans+=[0,1][k>ma or k<mi];ma=[ma,k][k>ma];mi=[mi,k][k<mi] print(ans-1)
7
PYTHON3
a = int(input()) b = list(input().split()) counter = 0 n = [] for i in range(a): b[i] = int(b[i]) max = b[0] min = b[0] for i in range(a): if b[i] > max: max = b[i] counter += 1 if b[i] < min: min = b[i] counter += 1 print(counter)
7
PYTHON3
n = int(input()) lst = list(map(int, input().split(' '))) best = lst[0] amazed = 0 low = lst[0] for i in lst: if i > best: amazed += 1 best = i elif i < low: low = i amazed += 1 print(amazed)
7
PYTHON3
n=int(input()) lst=list(map(int,input().strip().split(' '))) count=0 minm=lst[0] maxm=lst[0] for j in lst[1::]: if j<minm: minm=j count+=1 elif maxm<j: maxm=j count+=1 print(count)
7
PYTHON3
n = int(input()) amazing = 0 score = list(map(int, input().split())) for x in range(1, n): test = score[0: x + 1] if test[x] not in test[: x]: if test[x] == max(test): amazing += 1 elif test[x] == min(test): amazing += 1 print(amazing)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) min=l[0] max=l[0] c=0 for i in range(1,len(l)): if(l[i]>max): max=l[i] c+=1 elif(l[i]<min): min=l[i] c+=1 print(c)
7
PYTHON3
n=int(input()) a=[int(x) for x in input().split(' ')] maxi=a[0] mini=a[0] l=len(a) count=0 for i in range(1,l): if not mini<=a[i]<=maxi: count+=1 maxi=max(a[x] for x in range(0,i+1)) mini=min(a[x] for x in range(0,i+1)) print(count)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) mn = a[0] mx = a[0] ans = 0 for i in range(1, n): if a[i] < mn or a[i] > mx: ans += 1 mn = min(mn, a[i]) mx = max(mx, a[i]) print(ans)
7
PYTHON3
from operator import itemgetter #int(input()) #map(int,input().split()) #[list(map(int,input().split())) for i in range(q)] #print("YES" * ans + "NO" * (1-ans)) n = int(input()) ai = list(map(int,input().split())) mini = ai[0] maxi = ai[0] ans = 0 for i in range(1,n): if mini > ai[i]: mini = ai[i] ans += 1 if maxi < ai[i]: maxi = ai[i] ans += 1 print(ans)
7
PYTHON3
n = int(input()) a = [int(i) for i in input().split()] max = a[0] min = a[0] s = 0 for i in range(n): if a[i]>max: s+=1 max = a[i] elif a[i]<min: s+=1 min = a[i] print(s)
7
PYTHON3
n = int(input()) k = list(map(int, input().split())) az = 0 max = k[0] min = k[0] for i in range(n): if k[i] > max: max = k[i] az += 1 if k[i] < min: min = k[i] az += 1 print(az)
7
PYTHON3
n = int(input()) points = list(map(int, input().split())) max, min = points[0], points[0] res = 0 for x in points: if x < min: min = x res += 1 if x > max: max = x res += 1 print(res)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int points[n]; cin >> points[0]; int min(points[0]), max(points[0]), amazing(0); for (int i = 1; i < n; i++) { cin >> points[i]; if (points[i] < min) { min = points[i]; ++amazing; } if (points[i] > max) { max = points[i]; ++amazing; } } cout << amazing << endl; return 0; }
7
CPP
n=int(input()) a=list(map(int,input().split())) print(sum(a[i]>max(a[:i]) or a[i]<min(a[:i]) for i in range(1,n)))
7
PYTHON3
input() arr=[int(x) for x in input().split()] mn,mx=arr[0],arr[0] cnt=0 for i in range(1,len(arr)): if arr[i]<mn: mn=arr[i] cnt+=1 elif arr[i]>mx: mx=arr[i] cnt+=1 else: continue print(cnt)
7
PYTHON3
n=int(input()) a=[int(i) for i in input().strip().split()] mini=a[0] maxi=a[0] ans=0 for i in range(1,n): if a[i]>maxi: maxi=a[i] ans+=1 elif a[i]<mini: mini=a[i] ans+=1 print(ans)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) c=0 for i in range(1,n): j=arr[0:i] if arr[i] > max(j) or arr[i]<min(j): c+=1 print(c)
7
PYTHON3
import math def f(): n = int(input()); total = 0 li = list(map(int,input().split())) hi = li[0]; low = li[0] for x in range(1,n): if li[x] > hi: total += 1 hi = li[x] if li[x] < low: total += 1 low = li[x] print(total) f()
7
PYTHON3
n = int(input()) scores = list(map(int, input().split())) cnt = 0 for i in range(1, n): if scores[i] > max(scores[:i]): cnt += 1 if scores[i] < min(scores[:i]): cnt += 1 print(cnt)
7
PYTHON3
n=int(input()) x=list(map(int,input().split())) min=x[0] max=x[0] c=0 for i in range(1,n): if x[i]>max: c+=1 max=x[i] if x[i]<min: c+=1 min=x[i] print(c)
7
PYTHON3
n = int(input()) s = input().split() l = [] count = 0 for i in s: l.append(int(i)) l2 = [] big = l[0] small = l[0] flag=True for j in l: if j>big: big=j count=count+1 elif j<small: small = j count = count+1 print(count)
7
PYTHON3
n = int(input()) arr = list(map(int, input().split())) mmin = arr[0] mmax = arr[0] ans = 0 for i in range (1, n): if arr [i] > mmax: mmax = arr [i] ans += 1 if arr [i] < mmin: mmin = arr [i] ans += 1 print(ans)
7
PYTHON3
n=int(input()) s=[int(i) for i in input().split()] A=0;M,m=s[0],s[0] for i in range(n) : if s[i]<m : A+=1 m=s[i] if s[i]>M : A+=1 M=s[i] print(A)
7
PYTHON3
from sys import stdin n=int(input()) a=[int(x) for x in stdin.readline().split()] maxx=a[0] minn=a[0] val=0 for i in range(1,n): if maxx<a[i] or minn>a[i] : val += 1 maxx=max(a[0:i+1]) minn=min(a[0:i+1]) print(val)
7
PYTHON3
n=int(input()) a=list(map(int,input().rstrip().split())) c=0 p=0 d=0 q=0 for i in range(n): c=0 for j in range(i): if(a[i]>a[j]): c=c+1 if(c==i and c>0): p=p+1 for i in range(n): d=0 for j in range(i): if(a[i]<a[j]): d=d+1 if(d==i and d>0): q=q+1 print(p+q)
7
PYTHON3
#list(map(int,input().split())) n=int(input()) l=list(map(int,input().split())) c=0 mi=l[0] ma=l[0] for i in l[1:]: if i not in range(mi,ma+1): c+=1 mi=min(mi,i) ma=max(ma,i) print(c)
7
PYTHON3
n = int(input()) lst = [int(i) for i in input().split()] indexMax = 0 indexMin = 0 count = 0 for i in range(len(lst)): if lst[i] < lst[indexMin]: indexMin = i count += 1 if lst[i] > lst[indexMax]: indexMax = i count += 1 print(count)
7
PYTHON3
n = int (input ()) a = list (map (int, input ().split ())) perf = [] unik = [] for i in range (len (a)): if i == 0: perf.append (a[i]) else: if a[i] < min(perf) or a[i] > max(perf): unik.append (a[i]) perf.append (a[i]) print (len (unik))
7
PYTHON3
n = int(input()) ip = [int(i) for i in input().split()] best = ip[0] worst = ip[0] amaze = 0 for i in range(1, len(ip)): if (ip[i] > best): best = ip[i] amaze += 1 elif (ip[i] < worst): worst = ip[i] amaze += 1 print(amaze)
7
PYTHON3
a, b = int(input()), input().split(" ") d = 0 u = 0 for i in range(0, a): b[i] = int(b[i]) for i in range(1, a): for i2 in range(0, i): if b[i2] <= b[i]: u = - 1 if u == 0: d += 1 u = 0 for i2 in range(0, i): if b[i2] >= b[i]: u = - 1 if u == 0: d += 1 u = 0 print(d)
7
PYTHON3
from collections import defaultdict def main(): n = int(input()) rating = list(map(int, input().split())) mn = rating[0] mx = rating[0] cnt = 0 for rate in rating[1:]: if rate > mx: cnt += 1 mx = rate elif rate < mn: cnt += 1 mn = rate print(cnt) main()
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) mini=a[0] maxa=a[0] count=0 for i in range(1,n): if a[i]>maxa: maxa=a[i] count+=1 elif a[i]<mini: mini=a[i] count+=1 print(count)
7
PYTHON3
n=int(input()) p=[int(i) for i in input().split()] max=p[0] min=p[0] s=0 for i in range(1,n): if(p[i]>max): max=p[i] s=s+1 elif(p[i]<min): min=p[i] s=s+1 print(s)
7
PYTHON3
n = int(input()) lst = list(map(int,input().split())) maxi = lst[0] mini = lst[0] res = 0 for i in range(1,n): if lst[i]>maxi: res+=1 maxi = lst[i] elif lst[i]<mini: res+=1 mini=lst[i] print(res)
7
PYTHON3
n = input() x = list(map(int,input().split())) Min = x[0] Max = x[0] count = 0 for i in range(1 , len(x)) : if x[i] < Min : count += 1 Min = x[i] if x[i] > Max : count += 1 Max = x[i] print(count)
7
PYTHON3
number_of_contest = int(input()) points_earned = [int(i) for i in input().split()] lowest = points_earned[0] highest = points_earned[0] count = 0 for i in range(number_of_contest): if points_earned[i] < lowest: count += 1 lowest = points_earned[i] elif points_earned[i] > highest: count += 1 highest = points_earned[i] print(count)
7
PYTHON3
n = int(input()) li = list(map(int, input().split())) answ = 0 max = li[0] min = li[0] for i in range(1, len(li)): if li[i] < min: min = li[i] answ += 1 elif li[i] > max: max = li[i] answ += 1 print(answ)
7
PYTHON3
##### A. I_love_%username% amazing=0 n=int(input()) point=list(map(int,input().split())) mini=point[0] maxi=point[0] for i in point: if maxi<i: maxi=i amazing+=1 elif mini>i: mini=i amazing+=1 print(amazing)
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] a=l[0] b=l[0] c=0 if n==1: print('0') else: for i in l[1:]: if i>a: a=i c+=1 if i<b: b=i c+=1 print(c)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) maxi = mini = a[0] cnt = 0 for i in a: if i > maxi: cnt += 1 maxi = i if i < mini: cnt += 1 mini = i print(cnt)
7
PYTHON3
input() l=list(map(int,input().split())) a=max(l[:2]) b=min(l[:2]) x=int(a!=b) for i in l[2:]: if i>a : x+=1 a=i if i<b: x+=1 b=i print(x)
7
PYTHON3
N=int(input()) lista=[int(x) for x in input().split()] contador=0 menor=lista[0] mayor=lista[0] for i in range(len(lista)): if(lista[i]<menor): menor=lista[i] contador+=1 if(mayor<lista[i]): mayor=lista[i] contador+=1 print(contador)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int mn = INT_MAX, mx = INT_MIN, amaz = 0; for (int i = 0; i < n; i++) { if (i != 0) { if (arr[i] > mx) { amaz++; mx = arr[i]; } if (arr[i] < mn) { amaz++; mn = arr[i]; } } if (i == 0) { mx = arr[i]; mn = arr[i]; } } cout << amaz; } int main() { int t = 1; while (t--) { solve(); } return 0; }
7
CPP
nStr = input() n = int(nStr) pointStr = input() pointLine = pointStr.split() pMax = -1 pMin = 10001 amazing = -2 for i in range(n): point = int(pointLine[i]) if point>pMax: amazing = amazing+1 pMax = point if point<pMin: amazing = amazing+1 pMin = point print(amazing)
7
PYTHON3
n=int(input('')) p=[int(i) for i in input('').split(' ')] a=0 for i in range(1,n): if all(p[i]>x for x in p[:i]) or all(p[i]<x for x in p[:i]): a+=1 print(a)
7
PYTHON3
n=int(input()) perf= list(map(int, input().split())) worst=best=perf[0] count=0 for i in range(1, n): if perf[i]>best: best=perf[i] count+=1 elif perf[i]<worst: worst=perf[i] count+=1 else: pass print(count)
7
PYTHON3
n = int(input()) a = list(map(int,input().split())) s = 0 for i in range(1,n): if a[i] > max(a[:i]) or a[i] < min(a[:i]): s += 1 print (s)
7
PYTHON3
n=int(input()) l=[int(a) for a in input().split()] c=0 for i in range(len(l)): if i>0 and (l[i]>max(l[:i]) or l[i]<min(l[:i])): c+=1 print(c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int x; int counter = 0; cin >> x; int lowest; int increased; int arr[x]; for (int i = 0; i < x; i++) { cin >> arr[i]; } lowest = arr[0]; increased = lowest; for (int i = 1; i < x; i++) { if (lowest > arr[i]) { counter++; lowest = arr[i]; } else if (increased < arr[i]) { counter++; increased = arr[i]; } } cout << counter << endl; return 0; }
7
CPP
n=int(input()) line=input().split() line1=[] x,y=0,0 for i in range(n): line[i]=int(line[i]) line1.append(int(line[i])) for i in range(1,n): if line[i]>line[0]: line[0]=line[i] x=x+1 for i in range(1,n): if line1[i]<line1[0]: line1[0]=line1[i] y=y+1 print(x+y)
7
PYTHON3
n,a,x=int(input()),list(map(int,input().split())),0 q,w=a[0],a[0] for i in range(1,len(a)): if q>a[i]: q=min(q,a[i]) x+=1 elif w<a[i]: w=max(w,a[i]) x+=1 print(x)
7
PYTHON3
n = int(input()) points = [int(x) for x in input().strip().split()] lowest = highest = points[0] result = 0 for point in points[1:]: if point < lowest: lowest = point result += 1 elif point > highest: highest = point result += 1 print(result)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int i, j, k; for (i = 0; i < n; i++) cin >> a[i]; int max = a[0], min = a[0], x = 0, y = 0; max = a[0]; min = a[0]; for (i = 1; i < n; i++) { if (max < a[i]) { max = a[i]; x++; } if (min > a[i]) { min = a[i]; x++; } } cout << x << endl; return 0; }
7
CPP
n=int(input()) line=input() ls=line.split() a=int(ls[0]) b=int(ls[0]) t=0 for i in range(1,n): c=int(ls[i]) if c>b: t+=1 b=c if a>c: t+=1 a=c print(t)
7
PYTHON3
n = int(input()) lst = list(map(int, input().split())) x = lst[0] y = lst[0] a = b = 0 if len(lst) == 1: print(0) else: for i in lst: if i > x: x = i a += 1 for i in lst: if i < y: y = i b += 1 print(a + b)
7
PYTHON3
def get_number(ls): count = 0 indexes = list() for i in range(1, len(ls)): xs = ls[:i+1] if (min(xs) == ls[i] or max(xs) == ls[i]) and xs.count(ls[i]) == 1: indexes.append(i+1) count += 1 return count if __name__ == '__main__': n = int(input()) ls = [int(i) for i in input().split()] print(get_number(ls))
7
PYTHON3
n=int(input()) s=list(map(int,input().split())) min=s[0] max=s[0] ans=0 for i in range(1,n): if s[i]<min: ans+=1 min=s[i] if s[i]>max: ans+=1 max=s[i] print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5 + 3; int n, f, awesome; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; cin >> f; int maximum = f; int minimum = f; for (int i = 1; i < n; i++) { cin >> f; if (f > maximum) { awesome++; maximum = f; continue; } if (f < minimum) { awesome++; minimum = f; continue; } } cout << awesome << endl; }
7
CPP
n = int(input()) numbers = input().split() less = int(numbers[0]) more = int(numbers[0]) total = 0 for i in range(0, n): if int(numbers[i]) > more: more = int(numbers[i]) total += 1 elif int(numbers[i]) < less: less = int(numbers[i]) total += 1 print(total)
7
PYTHON3
n = int(input()) p = [int(i) for i in input().split()] q, r = p[0], p[0] count = 0 for i in range(1, n): if p[i] > q: count += 1 q = p[i] elif p[i] < r: count += 1 r = p[i] print(count)
7
PYTHON3
n=int(input()) s=list(map(int, input().split())) a=s[0] c=0 l=[] t=[] l.append(a) t.append(a) for i in range(1,len(s)): co=0 for j in range(len(l)): if s[i]>l[j]: co=co+1 if co==len(l): c=c+1 l.append(s[i]) for i in range(1,len(s)): co=0 for j in range(len(t)): if s[i]<t[j]: co=co+1 if co==len(t): c=c+1 t.append(s[i]) print(c)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) _min = a[0] _max = a[0] amazing = 0 for i in range(1, n): if a[i] > _max: amazing += 1 _max = a[i] elif a[i] < _min: amazing += 1 _min = a[i] print(amazing)
7
PYTHON3
n=int(input()) p=input().split() P=[int(p[0])] s=0 for i in range(1,n): if int(p[i])>max(P) or int(p[i])<min(P): s=s+1 P.append(int(p[i])) print(s)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) b = [] k = 0 m = 0 s = 0 for i in a: b.append(i) if (i > k or i < m) and i != a[0]: s = s + 1 k = max(b) m = min(b) print(s)
7
PYTHON3
n = int(input()) sp = list(map(int, input().split())) mn = sp[0] mx = mn k = 0 for i in range(1,n): if sp[i] < mn: k += 1 mn = sp[i] elif sp[i] > mx: k += 1 mx = sp[i] print(k)
7
PYTHON3
n = int(input()) x = list(map(int,input().split())) mi = x[0] ma = x[0] sum = 0 for i in range(1, n): if x[i] > ma: ma = x[i] sum += 1 if x[i] < mi: mi = x[i] sum += 1 print(sum)
7
PYTHON3
n = int(input()) s = list(map(int, input().split())) a = s[0] b = s[0] z = 0 u = 0 for i in s: if i>a: a = i z+=1 if i<b: b = i u+=1 print(z+u)
7
PYTHON3
n = int(input()) a = list(map(int,input().split())) min = max = a[0] c = 0 for i in range(1,n): if a[i]<min: min = a[i] c+=1 if a[i]>max: max = a[i] c+=1 print (c)
7
PYTHON3
n=int(input()) scores=list(map(int,input().split())) cnt_amazing_performances=0 for i in range (1,n): count1 = 0 count2 = 0 j, k = 0, 0 for j in range (i): if scores[i]>scores[j]: count1+=1 if count1==j+1: cnt_amazing_performances+=1 continue for k in range(i): if scores[i] < scores[k]: count2+= 1 if count2 == k+1: cnt_amazing_performances += 1 continue print(cnt_amazing_performances)
7
PYTHON3
n = int(input()) l = list(map(int,input().split())) ct = 0 for i in range(1,n): if l[i] > max(l[:i]) or l[i] < min(l[:i]): ct +=1 print(ct)
7
PYTHON3
n = int(input()) L = list(map(int,input().split())) ans = 0 for i in range(n): flag = 1 for j in range(i): if L[j] >= L[i]: flag = 0 break ans += flag flag = 1 for j in range(i): if L[j] <= L[i]: flag = 0 break ans += flag ans -= 2 print(ans)
7
PYTHON3
n = int(input()) contests = [int(x) for x in input().split()] counter = cmin = cmax = 0 def max_min(lst): if isinstance(lst, int): lst = [lst] return max(lst), min(lst) for idx, cntst in enumerate(contests): if idx == 0: cmax, cmin = max_min(contests[0]) continue if cntst > cmax: counter += 1 elif cntst < cmin: counter += 1 cmax, cmin = max_min(contests[:idx+1]) print(counter)
7
PYTHON3
n= int(input()) ls=list(map(int,input().split())) a=ls[0] ; b=ls[0] del ls[0] c=0 for i in ls: if i > a: c+=1 a=i if i < b: c+=1 b=i print(c)
7
PYTHON3
n = int(input()) data = [] inp = input() inpchars = inp.split(" ") for i in inpchars: data.append(int(i)) high = data[0] low = data[0] amazing = 0 for i in data: if i>high: high=i amazing+=1 elif i<low: low=i amazing+=1 print (amazing)
7
PYTHON3
numCont = int(input()) contests = list(map(int, input().split())) amazings = 0 maxScore = contests[0] minScore = contests[0] for i in range(numCont): if contests[i] > maxScore: amazings += 1 maxScore = contests[i] elif contests[i] < minScore: amazings += 1 minScore = contests[i] print(amazings)
7
PYTHON3
n=int(input()) L=list(map(int,input().split(" "))) L2=[] L2.append(L[0]) cnt=0 for i in range(1,n): if L[i]>max(L2) or L[i]<min(L2): cnt+=1 L2.append(L[i]) print(cnt)
7
PYTHON3
n=int(input()) l=[int(x) for x in input().split()] count=0 a=l[0] l=l[1:] l1=[a] for i in l: if i>max(l1) or i<min(l1): count+=1 l1.append(i) print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int count = 0; int maxi = a[0]; int mini = a[0]; for (int i = 1; i < n; i++) { if (a[i] > maxi || a[i] < mini) { count++; } maxi = max(maxi, a[i]); mini = min(mini, a[i]); } cout << count; return 0; }
7
CPP
n=int(input()) p=input().split() i=0 s=[] while i<n: s.append(int(p[i])) i+=1 i=1 ans=0 while i<n: a=s[:i] if s[i]>max(a) or s[i]<min(a): ans+=1 i+=1 print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { vector<int> scores; int x, con, a = 0; cin >> x; cin >> con; scores.push_back(con); for (int i = 0; i < x - 1; i++) { cin >> con; if ((con > *max_element(scores.begin(), scores.end())) || (con < *min_element(scores.begin(), scores.end()))) a++; scores.push_back(con); } cout << a; return 0; }
7
CPP
n = int(input()) l = [int(x) for x in input().split()] mx = l[0] mini = l[0] count = 0 for x in l: if x > mx: count += 1 mx = x if x < mini: count += 1 mini = x print(count)
7
PYTHON3
n=int(input()) p=[int(x) for x in input().split()] if n==1: print(0) elif n==2: if p[0]==p[1]: print(0) else: print(1) else: a=max(p[0],p[1]) b=min(p[0],p[1]) if a>b: t=1 else: t=0 for i in range (2,n): if p[i]>a: a=p[i] t+=1 elif p[i]<b: b=p[i] t+=1 print(t)
7
PYTHON3
n=int(input()) ct=list(map(int,input().split())) hi=[ct[0]] amz=0 for i in range(1,n): if ct[i]>max(hi) or ct[i]<min(hi): amz+=1 hi.append(ct[i]) print(amz)
7
PYTHON3
n=int(input()) a=list(map(int,input().split(' '))) count=0 for i in range(1,len(a)): if a[i]<min(a[0:i]) or a[i]>max(a[0:i]): count+=1 print(count)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) min1=arr[0] max1=arr[0] ans=0 for i in range(1,n): if arr[i]<min1: ans+=1 min1=arr[i] if arr[i]>max1: ans+=1 max1=arr[i] print(ans)
7
PYTHON3
n = int(input()) a = [int(i) for i in input().split()] d = 0 for i in range(1,n): b = 0 c = 0 for j in range(i): if a[j] < a[i]: b += 1 elif a[j] > a[i]: c += 1 if b == i or c == i: d += 1 print(d)
7
PYTHON3
input() s = list(map(int, input().split())) count = 0 min = s[0] max = s[0] for i in s: if i < min: count += 1 min = i elif i > max: count += 1 max = i else: pass print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(void) { int a, count = 0; cin >> a; int arr[a - 1]; for (int i = 0; i < a; i++) cin >> arr[i]; int max = arr[0]; int min = arr[0]; for (int i = 1; i < a; i++) { if (arr[i] < min) { min = arr[i]; count++; } else if (arr[i] > max) { max = arr[i]; count++; } } cout << count << endl; }
7
CPP
n = int(input()) a = [int(x) for x in input().split()] _min = a[0] _max = a[0] l = 0 for i in a[1:]: if i < _min: _min = i l += 1 if i > _max: _max = i l += 1 print(l)
7
PYTHON3
times = int(input()) points = [int(i) for i in input().split()] max, min = points[0], points[0] superior = 0 for i in range(1, times): if points[i] > max: max = points[i] superior += 1 elif points[i] < min: min = points[i] superior += 1 print(superior)
7
PYTHON3
def hachiman(l): mx, mn = l[0], l[0] cnt = 0 for i in l: if i > mx: cnt += 1 mx = i elif i < mn: cnt += 1 mn = i return cnt n = int(input()) l = list(map(int, input().split())) print(hachiman(l))
7
PYTHON3
a=int(input()) k=[] k=list(map(int,input().split())) mn=k[0] mx=k[0] kl=0 for i in k: if i>mx: kl+=1 mx=i if i<mn: kl+=1 mn=i print(kl) #fd
7
PYTHON3
n=int(input()) scores=list(map(int,input().split())) hs=ls=scores[0] hcount=lcount=0 for i in range(len(scores)): if scores[i]>hs: hs=scores[i] hcount+=1 elif scores[i]<ls: ls=scores[i] lcount+=1 print(hcount+lcount)
7
PYTHON3
# =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IOBase from itertools import * import bisect from heapq import * from math import * from copy import * from collections import deque from collections import Counter as counter # Counter(list) return a dict with {key: count} from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)] from itertools import permutations as permutate from bisect import bisect_left as bl # If the element is already present in the list, # the left most position where element has to be inserted is returned. from bisect import bisect_right as br from bisect import bisect # If the element is already present in the list, # the right most position where element has to be inserted is returned # ============================================================================================== # fast I/O region BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") def print(*args, **kwargs): """Prints the values to a stream, or to sys.stdout by default.""" sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout) at_start = True for x in args: if not at_start: file.write(sep) file.write(str(x)) at_start = False file.write(kwargs.pop("end", "\n")) if kwargs.pop("flush", False): file.flush() if sys.version_info[0] < 3: sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout) else: sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) # inp = lambda: sys.stdin.readline().rstrip("\r\n") # =============================================================================================== ### START ITERATE RECURSION ### from types import GeneratorType def iterative(f, stack=[]): def wrapped_func(*args, **kwargs): if stack: return f(*args, **kwargs) to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) continue stack.pop() if not stack: break to = stack[-1].send(to) return to return wrapped_func #### END ITERATE RECURSION #### # =============================================================================================== # some shortcuts mod = 1000000007 def inp(): return sys.stdin.readline().rstrip("\r\n") # for fast input def out(var): sys.stdout.write(str(var)) # for fast output, always take string def lis(): return list(map(int, inp().split())) def stringlis(): return list(map(str, inp().split())) def sep(): return map(int, inp().split()) def strsep(): return map(str, inp().split()) def zerolist(n): return [0] * n def nextline(): out("\n") # as stdout.write always print sring. def testcase(t): for p in range(t): solve() def printlist(a): for p in range(0, len(a)): out(str(a[p]) + ' ') def solve(): n=int(inp()) ar=lis() mi=ar[0] ma=ar[0] s=0 for i in ar: if i<mi: s+=1 mi=i elif i>ma: s+=1 ma=i print(s) solve()
7
PYTHON3
def main(): n=int(input()) a=list(map(int,input().split())) am=0 for i in range(1,n): mn=min(a[:i]) mx=max(a[:i]) if a[i]>mx or a[i]<mn: am+=1 print(am) if __name__=='__main__': main()
7
PYTHON3
n = int( input() ) m = list( map( int,input().split() ) ) max=m[0] min=m[0] c=0 for i in range(n): if m[i] > max: c+=1 max=m[i] elif m[i] < min: c+=1 min=m[i] print (c)
7
PYTHON3
n = int(input()) arr = list(map(int,input().split())) rs = 0 maxA = arr[0] minA = arr[0] for i in range(1,n): if(arr[i] > maxA): rs += 1 maxA = arr[i] if(arr[i] < minA): rs += 1 minA = arr[i] print(rs)
7
PYTHON3
n=input() p=input() p=p.split() s=[] for i in p: s.append(int(i)) amz=0 best=s[0] worst=s[0] for i in s: if i > best: best=i amz=amz+1 if i < worst: worst=i amz=amz+1 print(amz)
7
PYTHON3
n = int(input()) x = 0 a = 0 for i in list(map(int, input().split())): if a == 0: max = i min = i if min > i or max < i: if max < i: max = i else: min = i x += 1 a = 1 print(x)
7
PYTHON3
n=int(input()) s=[int(i) for i in input().split()] amaz=0 for i in range(1,n): if s[i]>max(s[:i]) or s[i]<min(s[:i]): amaz+=1 print(amaz)
7
PYTHON3