solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
n = int(input().strip()) ll = list(map(int,input().split())) kmin = ll[0] kmax = ll[0] jav = 0 for i in range(1,n): if kmax < ll[i]: kmax = ll[i] jav += 1 elif kmin > ll[i]: jav += 1 kmin = ll[i] print(jav)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split()] count = 0 #if a[1] < a[0] or a[1] > a[0]: # count += 1 for i in range(1, len(a)): if a[i] > max(a[:i]) or a[i] < min(a[:i]): count += 1 print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) mi=l[0] ma=l[0] c=0 for i in range(1,n): if(l[i]>ma): ma=l[i] c+=1 if(l[i]<mi): mi=l[i] c+=1 print(c)
7
PYTHON3
n = int(input()) scores = [ i for i in map(int,input().split())] ans = 0 for i in range(1,n): if (scores[i] == max(scores[:i+1]) and scores[:i+1].count(max(scores[:i+1])) == 1) or (scores[i] == min(scores[:i+1]) and scores[:i+1].count(min(scores[:i+1])) == 1): ans += 1 print(ans)
7
PYTHON3
n = int(input()) per = input().split() peri = [int(x) for x in per] score_p = 0 score_n = 0 amazing = set() for i in range(len(peri)): score_p = 0 score_n = 0 for j in range(i): if peri[i] > peri[j]: score_p += 1 if peri[i] < peri[j]: score_n += 1 if score_p == i and i != 0: amazing.add(peri[i]) if score_n == i and i != 0: amazing.add(peri[i]) print(len(amazing))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; int a[t]; for (int i = 0; i < t; i++) { cin >> a[i]; } int minim = a[0]; int maxim = a[0]; int count = 0; for (int i = 0; i < t; i++) { if (i == 0) { continue; } if (a[i] > maxim) { maxim = a[i]; count++; } else if (a[i] < minim) { minim = a[i]; count++; } } cout << count << "\n"; }
7
CPP
def stringtonum(string): i=0 number=[] array1=[] array=[] string= string+" " while i<len(string): if string[i]!=" ": number.append(string[i]) else: array.append(number) number=[] i=i+1 j=0 while j<len(array): k=0 s="" while k<len(array[j]): s=s+array[j][k] k=k+1 s=int(s) array1.append(s) j=j+1 l=0 return(array1) n=int(input()) i=1 s=input() result=stringtonum(s) Min=result[0] Max=result[0] a=0 while i<n: if result[i]>Max: a=a+1 Max=result[i] elif result[i]<Min: a=a+1 Min=result[i] i=i+1 print(a)
7
PYTHON3
#code def score(lst,n): count=0 for i in range(1,n): if lst[i]<lst[i-1]: flag=True for j in range(i-1,-1,-1): if lst[i]>=lst[j]: flag=False break if flag==True: count+=1 elif lst[i]>lst[i-1]: flag=True for j in range(i-1,-1,-1): if lst[i]<=lst[j]: flag=False break if flag==True: count+=1 return count n=int(input()) lst=list(map(int,input().split())) print(score(lst,n))
7
PYTHON3
""" β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ•β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β•šβ•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β• """ __author__ = "Dilshod" n = int(input()) mn = float("inf") mx = -float("inf") m = list(map(int, input().split())) cnt = 0 for i in range(n): if i == 0: mn = m[i] mx = m[i] else: if m[i] < mn: cnt += 1 mn = m[i] if m[i] > mx: cnt += 1 mx = m[i] print(cnt)
7
PYTHON3
n = int(input()) A = input().split() point = [] for i in range (n): point.append(int(A[i])) C = 0 for i in range (2,n + 1): forcet = point[0:i - 1] if point[i - 1] > max(forcet): C = C + 1 elif point[i - 1] < min(forcet): C = C + 1 print(C)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) c=0 for i in range(1,n): if (a[i]>max(a[0:i])) or (a[i] < min(a[0:i])): c=c+1 print(c)
7
PYTHON3
# Problem 155 A - I love username # input n = int(input()) nums = list(map(int, input().split())) # initialization tmp_nums = [nums.pop(0)] count = 0 # count for num in nums: is_less = True is_more = True # less check for t in tmp_nums: if t<=num: is_less = False # more check for t in tmp_nums: if t>=num: is_more = False # check if is_less or is_more: count += 1 # next step tmp_nums.append(num) # output print(count)
7
PYTHON3
n=int(input()) scores=[int(x) for x in input().split()] sma=lar=scores[0] amaz=0 for i in scores[1:]: if(i<sma): sma=i amaz=amaz+1 if(i>lar): lar=i amaz=amaz+1 print(amaz)
7
PYTHON3
n=int(input()) s=input() ls=[int(x) for x in s.split()] ma=ls[0] mi=ls[0] c=0 for i in range(1,n): if ls[i]<mi: mi=ls[i] c+=1 if ls[i]>ma: ma=ls[i] c+=1 print(c)
7
PYTHON3
n = int(input()) points = input().split() max_points = int(points[0]) min_points = int(points[0]) count = 0 for i in range(1, n): compare = int(points[i]) if compare > max_points: max_points = compare count += 1 elif compare < min_points: min_points = compare count += 1 print(count)
7
PYTHON3
n = int(input()) div = 0 s = input().split() s = [int (i) for i in s] max = s[0] min = s[0] for i in range(len(s)): if s[i] > max: max = s[i] div += 1 elif s[i] < min: min = s[i] div += 1 print(div)
7
PYTHON3
n = int(input()) ans = 0 arr = [] cnt = 0 for i in input().split(): if cnt == 0: arr.append(int(i)) else: if int(i) > max(arr) or int(i) < min(arr): ans += 1 arr.append(int(i)) cnt += 1 print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int i, min, max, t = 0, n, a; cin >> n >> a; min = a, max = a; for (i = 1; i < n; i++) { cin >> a; if (a > max) { max = a; t++; } if (a < min) { min = a; t++; } } cout << t << endl; return 0; }
7
CPP
import sys import math import bisect def main(): n = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(1, n): if A[i] > max(A[0:i]): ans += 1 elif A[i] < min(A[0:i]): ans += 1 print(ans) if __name__ == "__main__": main()
7
PYTHON3
n = int(input()) a = input().split() for i in range(n): a[i]= int(a[i]) if n <= 1: print(0) else: count = 0 for i in range(n): countd = 0 countx = 0 for j in range(i): if a[i]>a[j]: countd += 1 elif a[i]<a[j]: countx += 1 if countd == i or countx == i: count += 1 print(count-1)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split()] if len(a)==1: amazing = 0 else: amazing = 1 if a[1]<a[0]: mini = a[1] maxi = a[0] elif a[1]==a[0]: mini = a[0] maxi = a[1] amazing-=1 else: mini = a[0] maxi = a[1] for i in a[2:]: if i>maxi: maxi = i amazing+=1 elif i<mini: mini = i amazing+=1 print(amazing)
7
PYTHON3
import sys n = int(sys.stdin.readline().split()[0]) scores = [int(i) for i in sys.stdin.readline().split()] amazing = 0 i = 1 while i < len(scores): j = i - 1 less_count = 0 more_count = 0 while j >= 0: if scores[i] > scores[j]: less_count += 1 if scores[i] < scores[j]: more_count += 1 j -= 1 if less_count == i or more_count == i: amazing += 1 i += 1 print(amazing)
7
PYTHON3
n = int(input()) results = [int(x) for x in input().split()] r_min, r_max = results[0], results[0] counter = 0 for i in range(1, n): if r_min > results[i]: counter += 1 r_min = results[i] elif r_max < results[i]: counter += 1 r_max = results[i] print(counter)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split(' ')] cnt = 0 for i in range(len(a)): if i != 0: sub = a[0:i] ma = max(sub) mi = min(sub) if a[i] < mi or a[i] > ma: cnt += 1 print(cnt)
7
PYTHON3
def ismin(l,i): k=0 while k<=i: if l[i]>=l[k] and i!=k: return 0 k+=1 return 1 def ismax(l,i): k=0 while k<=i: if l[i]<=l[k] and i!=k: return 0 k+=1 return 1 n=int(input()) l=[int(x) for x in input().split()] i=1 cnt=0 while i<n: if ismin(l,i) or ismax(l,i): cnt+=1 i+=1 print(cnt)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) temp=[] ans=0 for i in range(n): if i==0: temp.append(arr[i]) else: if max(temp)<arr[i]: ans+=1 if min(temp)>arr[i]: ans+=1 temp.append(arr[i]) print(ans)
7
PYTHON3
n=int(input()) points=[int(x) for x in input().split()] amazing=0 maxpoint=points[0] minpoint=points[0] for i in range(n): if points[i]<minpoint: amazing+=1 minpoint=points[i] elif points[i]>maxpoint: amazing+=1 maxpoint=points[i] print(amazing)
7
PYTHON3
n=int(input()) s=[int(x) for x in input().split()] z=0 c=0 Max=0 Mini=0 for i in s: if z==0: Max=i Mini=i z+=1 else: if i>Max: Max=i c+=1 if i<Mini: Mini=i c+=1 print(c)
7
PYTHON3
n=int(input()) list=[int(i) for i in input().split()] list1=[] list1.append(list[0]) list.pop(0) sum=0 for i in list: if i<min(list1) or i>max(list1): sum=sum+1 else: pass list1.append(i) print(sum)
7
PYTHON3
noOfCases = int(input()) listOfNum = [int(x) for x in input().split()] best = listOfNum[0] countB = 0 worst = listOfNum[0] countW = 0 for i in range(1, noOfCases): if listOfNum[i] > best: best = listOfNum[i] countB += 1 if listOfNum[i] < worst: worst = listOfNum[i] countW += 1 print(countB+countW)
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] if n==1: print(0) elif n==2 and l[0]==l[1]: print(0) elif n==2 and l[0]!=l[1]: print(1) else: a=max(l[0],l[1]) b=min(l[0],l[1]) if a==b: sum=0 else: sum=1 for i in range(2,n): if l[i]>a: a=l[i] sum=sum+1 elif l[i]<b: b=l[i] sum=sum+1 else: continue print(sum)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) k=a[0] p=a[0] count=0 for i in range(1,n): if k<a[i]: count+=1 k=a[i] if p>a[i]: count+=1 p=a[i] print(count)
7
PYTHON3
n = int(input()) if(n==1): print(0) exit() scores = [int(n) for n in input().split()] amazing = 1 equal=False if(scores[1]==scores[0]): equal=True if (scores[1] > scores[0]): minscore = scores[0] maxscore = scores[1] else: minscore = scores[1] maxscore = scores[0] for i in range(2, n): if (scores[i] < minscore): minscore = scores[i] amazing += 1 if (scores[i] > maxscore): maxscore = scores[i] amazing += 1 if(equal): print(amazing-1) else: print(amazing)
7
PYTHON3
n=int(input()) point=[int(i) for i in input().split()] da,xiao=point[0],point[0] cishu=0 for i in range(1,n): if point[i]>da: da=point[i] cishu += 1 if point[i]<xiao: xiao=point[i] cishu += 1 print(cishu)
7
PYTHON3
a=int(input()) b=input().split() i=1 j=0 x=0 y=0 r=0 z=0 lst=[] for i in range(a): x=0 y=0 z=0 for j in range(i): if(int(b[i])<int(b[j])): x=x+1 elif(int(b[i])>int(b[j])): y=y+1 elif(int(b[i])==int(b[j])): z=z+1 if((x>0 and y==0 and z==0) or (y>0 and z==0 and x==0) or (z>0 and x==0 and z==0)): r=1 lst.append(r) print(len(lst))
7
PYTHON3
n = int(input()) m = list(map(int, input().split())) result = [] max = m[0] min = m[0] for i in range(1, len(m)): if m[i] > max or m[i] < min: result.append(m[i]) if m[i] < min: min = m[i] elif m[i] > max: max = m[i] print(len(result))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; int dx[] = {0, 0, +1, -1}; int dy[] = {+1, -1, 0, 0}; template <typename first, typename second> ostream &operator<<(ostream &os, const pair<first, second> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << *it; } return os << "}"; } template <typename T> ostream &operator<<(ostream &os, const set<T> &v) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << *it; } return os << "]"; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << *it; } return os << "]"; } template <typename first, typename second> ostream &operator<<(ostream &os, const map<first, second> &v) { os << "["; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ", "; os << it->first << " = " << it->second; } return os << "]"; } void faltu() { cerr << '\n'; } template <typename T> void faltu(T a[], int n) { for (int i = 0; i < n; ++i) cerr << a[i] << ' '; cerr << '\n'; } template <typename T, typename... hello> void faltu(T arg, const hello &...rest) { cerr << arg << ' '; faltu(rest...); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int a, count = 0, store = 0; cin >> a; int arr[a]; for (int i = 0; i < a; i++) { cin >> arr[i]; } int max = arr[0]; int min = arr[0]; for (int i = 0; i < a; i++) { if (arr[i] > max) { max = arr[i]; count++; } if (arr[i] < min) { min = arr[i]; count++; } } cout << count; return 0; }
7
CPP
a=int(input()) b=input() c=b.split() d=[] for i in c: d.append(int(i)) min=d[0] max=d[0] #print(min,max) count=0 for i in d: if i>max: count+=1 max=i # print('l') if i<min: count+=1 min=i #print('s') print(count) #print(d)
7
PYTHON3
n = int(input()) points = list(map(int,input().split())) amazing = 0 min_for_now = 0 max_for_now = 0 for i in range(n): if i == 0: min_for_now = points[i] max_for_now = points[i] else: if points[i] > max_for_now: amazing +=1 max_for_now = points[i] elif points[i] < min_for_now: amazing +=1 min_for_now = points[i] print(amazing)
7
PYTHON3
N=int(input("")) Line2=input("") arr=list(map(int, Line2.split(' '))) max_min=[] max_min.append(arr[0]) counter=0 for itr in range(1, len(arr)): if arr[itr] > max(max_min): max_min.append(arr[itr]) counter+=1 if arr[itr]<min(max_min): max_min.append(arr[itr]) counter+=1 print(counter)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, m; bool debug = false; int k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int main() { int l, r, ans = 0; scanf("%d", &n); for (int(i) = 0; (i) < (int)(n); (i)++) { scanf("%d", &m); if (!i) { l = r = m; } else { if (m > r) { ans++; r = m; } else if (m < l) { ans++; l = m; } } } printf("%d\n", ans); return 0; }
7
CPP
n=int(input()) h=0 a=[int(i) for i in input().split()] min=a[0] max=a[0] for i in range(n): if a[i] < min: min=a[i] h+=1 elif a[i] > max: max=a[i] h+=1 print(h)
7
PYTHON3
num = int(input()) n = input() l = map(int,n.split()) main = list(l) maxi= main[0] mini = main[0] amazing = 0 for i in main: if i > maxi: maxi = i amazing += 1 elif i < mini: mini = i amazing += 1 print(amazing)
7
PYTHON3
n = int(input()) arr = list(map(int, input().split())) mx= arr[0] mn = arr[0] c = 0 for i in range(1, n): if arr[i] > mx or arr[i] < mn: c += 1 mx = max(arr[i], mx) mn = min(arr[i], mn) print(c)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split()] dp = [a[0], a[0]] count = 0 for val in a: if val < dp[0]: dp[0] = val count += 1 if val > dp[1]: dp[1] = val count += 1 print(count)
7
PYTHON3
n=int(input()) if(n==1): a=int(input()) print('0') exit() a=[int(x) for x in input().split()] c=0 if(a[0]>a[1]): maxa=a[0] mina=a[1] c+=1 elif(a[0]<a[1]): maxa=a[1] mina=a[0] c+=1 if(c==0): maxa=a[0] mina=a[1] for i in range(2,n): if(a[i]>maxa or a[i]<mina): c+=1 if(a[i]>maxa): maxa=a[i] else: mina=a[i] print(c)
7
PYTHON3
n=int(input()) line=[int(x) for x in input().split()] ma=line[0] mi=line[0] sur=0 for i in range(1,n): if(line[i]>ma): ma=line[i] sur+=1 elif(line[i]<mi): mi=line[i] sur+=1 print(sur)
7
PYTHON3
x = int(input()) y = list(map(int, input().split())) min = y[0] max = y[0] win = 0 for c in y: if c > max: win = win +1 max = c if c < min: win = win +1 min = c print(win)
7
PYTHON3
n=int(input()) L=[int(x) for x in input().split()] count=0 for i in range(1,len(L)): if L[i]>max(L[:i]): count+=1 elif L[i]<min(L[:i]): count+=1 print(count)
7
PYTHON3
integer = int string = str length = len def main(): n=integer(input()) l=list(map(integer,input().split())) minimum=l[0] maximum=l[0] ans=0 for i in l: if i < minimum: ans+=1 minimum=i elif i>maximum: ans+=1 maximum=i print(ans) main()
7
PYTHON3
n = int(input()) a = [int(i) for i in input().split()] minimum = a[0] maximum = a[0] amazing = 0 for i in range(1,n): if a[i]>maximum: amazing += 1 maximum = a[i] elif a[i]<minimum: amazing += 1 minimum = a[i] print(amazing)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) max=a[0] min=a[0] i=0 for l in a: if l>max: i+=1 max=l elif min>l: i+=1 min=l print(i)
7
PYTHON3
n=int(input()) arr=list(map(int, input().split())) m=arr[0] mi=arr[0] count=0 for i in arr: if i>m or i<mi: count+=1 m=max(m, i) mi=min(mi, i) print(count)
7
PYTHON3
n=int(input()) l=[] c=0 a=list(map(int,input().split())) l.append(a[0]) for i in range(1,n): if a[i]>max(l) or a[i]<min(l): c+=1 l.append(a[i]) print(c)
7
PYTHON3
def I_love_username(li): cnt = 0 for i in range(1,len(li)): if max(li[0:i]) < li[i] or min(li[0:i]) > li[i]: cnt += 1 return cnt n = input() li = map(int,input().split()) print(I_love_username(list(li)))
7
PYTHON3
from functools import reduce n = int(input()) points = [int(string) for string in input().split()] print(reduce(lambda r, c : (r[0] + (0 if (r[1] <= c and c <= r[2]) else 1), min(r[1], c), max(r[2], c)), points, (0, points[0], points[0]))[0])
7
PYTHON3
#include <bits/stdc++.h> int main(void) { long long n, t, i, min, max, co = 0, c = 0; scanf("%lld", &n); long long a[n]; for (i = 1; i <= n; i++) scanf("%lld", &a[i]); max = a[1]; min = a[1]; for (i = 2; i <= n; i++) { if (a[i] > max) { max = a[i]; c++; } else if (a[i] < min) { min = a[i]; co++; } } printf("%lld\n", co + c); }
7
CPP
n=int(input()) ar=list(map(int,input().split())) count=0 max1=ar[0];min1=ar[0] for i in range(1,n): if ar[i]>max1: count+=1 max1=ar[i] else: if ar[i]<min1: count+=1 min1=ar[i] print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split(" "))) mi=l[0] mx=l[0] c=0 for i in range(n): if(l[i]>mx): mx=l[i] c+=1 if(l[i]<mi): mi=l[i] c+=1 print(c)
7
PYTHON3
n=int(input()) x=[int(i) for i in input().split(' ')] max_v=x[0] min_v=x[0] s=0 for i in range(1,len(x)): if(x[i]>max_v): s+=1 max_v=x[i] if (x[i]<min_v): s+=1 min_v=x[i] print(s)
7
PYTHON3
a=int(input()) b=input().split() l=[int(b[0])] s=0 for i in range(a): m=max(l) n=min(l) p=int(b[i]) if p>m or p<n: s=s+1 l.append(p) print(s)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) r=0 k=[] k.append(l[0]) for i in range(len(l)): if l[i]>max(k): r+=1 k.append(l[i]) elif l[i]<min(k): r+=1 k.append(l[i]) print(r)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) mi=l[0] ma=l[0] k=0 for i in range(1,n) : if mi>l[i] : mi=l[i] k=k+1 if ma<l[i] : ma=l[i] k=k+1 print(k)
7
PYTHON3
n=int(input()) num=[int(i) for i in input().split()] s=0 q=num[0] p=num[0] for i in range(1,n): if num[i]<q: s+=1 q=num[i] if num[i]>p: s+=1 p=num[i] print(s)
7
PYTHON3
a=int(input()) m=[int(i) for i in input().split()] s=0 maximum=m[0] minimum=m[0] for i in range(len(m)): if maximum<m[i]: s+=1 maximum=m[i] if minimum>m[i]: s+=1 minimum=m[i] print(s)
7
PYTHON3
n=int(input()) a=list(input().split()) b=[] b.append(int(a[0])) k=0 for i in range(1,n): if int(a[i])<b[0] or int(a[i])>b[i-1]: k=k+1 b.append(int(a[i])) b=sorted(b) print(k)
7
PYTHON3
x=int(input()) numbers=input() numbers=numbers.split(" ") temp=0 low=int(numbers[0]) high=int(numbers[0]) for i in range(1,x): if int(numbers[i])>high: high=int(numbers[i]) temp+=1 elif int(numbers[i])<low: low=int(numbers[i]) temp+=1 print(temp)
7
PYTHON3
n = int(input()) point = list(map(int, input().split())) max_point = point[0] min_point = point[0] amazing = 0 for i in range(1,len(point)) : if point[i] > max_point : max_point = point[i] amazing += 1 elif point[i] < min_point : min_point = point[i] amazing += 1 print(amazing)
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] Amz=0 for i in range(1,n): if l[i]>max(l[:i]) or l[i]<min(l[:i]): Amz+=1 print(Amz)
7
PYTHON3
n=int(input()) scores=input().split() high=int(scores[0]) low=int(scores[0]) amazing=0 for i in range(n): if int(scores[i])>high: high=int(scores[i]) amazing+=1 if int(scores[i])<low: low=int(scores[i]) amazing+=1 print(amazing)
7
PYTHON3
n = int(input()) performances = list(map(int, input().split())) num_amazing = 0 mn = mx = -1 for i, performance in enumerate(performances): if i == 0: mn = mx = performance elif performance < mn: mn = performance num_amazing += 1 elif performance > mx: mx = performance num_amazing += 1 print(num_amazing)
7
PYTHON3
n = int(input()) points = list(map(int, input().split())) min, max = points[0], points[0] amazing_count = 0 for i in range(len(points)): if points[i] < min: amazing_count += 1 min = points[i] elif points[i] > max: amazing_count += 1 max = points[i] print(amazing_count)
7
PYTHON3
# python 3 num_contests = int(input()) scores = list(map(int, input().split())) min_score = scores[0] max_score = scores[0] amazing = 0 for idx in range(1, num_contests): if scores[idx] < min_score: amazing += 1 min_score = scores[idx] elif scores[idx] > max_score: amazing += 1 max_score = scores[idx] else: pass print(amazing)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) res=0 for i in range(1,n): f=0 for j in range(i): if arr[i]<=arr[j]: f=1 break if f==0: res+=1 for i in range(1,n): f=0 for j in range(i): if arr[i]>=arr[j]: f=1 break if f==0: res+=1 print(res)
7
PYTHON3
n = int(input()) pts=[int(i) for i in input().split()] count=0 if n <2: count=0 elif n==2: if pts[0]!=pts[1]: count=1 else: M=max(pts[0],pts[1]) m=min(pts[0],pts[1]) for i in range(1,n): if i ==1: if pts[i]!=pts[0]: count+=1 if pts[i]>M: count+=1 M=pts[i] if pts[i]<m: count+=1 m=pts[i] else: continue print(count)
7
PYTHON3
count = 0 num = int(input()) scores = list(map(int,input().split())) worst = scores[0] best = scores[0] for i in range(1,num): if scores[i] > best: best = scores[i] count += 1 if scores[i] < worst: worst = scores[i] count += 1 print(count)
7
PYTHON3
n = int(input()) mylist = input().split() for i in range(n): mylist[i] = int(mylist[i]) max = mylist[0] min = mylist[0] counter = 0 for i in range(1,n): if mylist[i] > max: max = mylist[i] counter+= 1 if mylist[i] < min: min = mylist[i] counter +=1 print(counter)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n; cin >> n; long long a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; } long long ans = 0, mn = a[0], mx = a[0]; for (int i = 0; i < n; ++i) { if (a[i] > mx) { ans++; mx = a[i]; } if (a[i] < mn) { ans++; mn = a[i]; } } cout << ans; }
7
CPP
n = int(input()) arr = list(map(int, input().split())) b = w = arr[0] count = 0 for i in arr[1:]: if i > b : b = i count += 1 if i < w: w = i count += 1 print(count)
7
PYTHON3
n = int(input()) scores = list(map(int, input().split())) maximum = scores[0] minimum = scores[0] count = 0 for i in range(1, n): if scores[i] > maximum: count += 1 maximum = scores[i] elif scores[i] < minimum: count += 1 minimum = scores[i] print(count)
7
PYTHON3
a=int(input()) prim=[int(i) for i in input().split()] ans=0 cal=[prim[0]] for i in range(1,a): cal.append(prim[i]) if max(cal)==cal[i] or min(cal)==cal[i]: if cal.count(cal[i])==1: ans+=1 print(ans)
7
PYTHON3
n=int(input()) c=0 l=[int(i) for i in input().split()] maxi=mini=l[0] for i in range(1,n): if l[i]>maxi: c+=1 maxi=l[i] if l[i]<mini: c+=1 mini=l[i] print(c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int minn, maxx; int n, ans; int main() { cin >> n; cin >> minn; maxx = minn; for (int i = 1; i < n; ++i) { int a; cin >> a; if (a > maxx) maxx = a, ans++; if (a < minn) minn = a, ans++; } cout << ans; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, Min, Max, cnt = 0, x; scanf("%d", &n); scanf("%d", &x); Max = x; Min = x; while (n--) { scanf("%d", &x); if (x > Max) { cnt++; Max = x; } if (x < Min) { cnt++; Min = x; } } printf("%d", cnt); }
7
CPP
n=int(input()) point=list(map(int, input().split())) count=0 maximum=point[0] minimum=point[0] for i in range(1, n): if point[i]>maximum: maximum=point[i] count+=1 elif point[i]<minimum: minimum=point[i] count+=1 print(count)
7
PYTHON3
n = int(input()) L = input() L = L.split() p = 1 for i in range (n): L[i] = int(L[i]) R = [L[0]] c = 0 for k in range (1,n): mayor = L[0] menor = L[0] for i in range (k+1): if (L[i] > mayor): mayor = L[i] if (L[i] < menor): menor = L[i] if L[k] not in R and (L[k] == mayor or L[k] == menor) and mayor != menor: R.append(L[k]) c += 1 print (c)
7
PYTHON3
lenn = int(input()) arr = list(map(int,input().split())) minn = arr[0] maxx = arr[0] count=0 for i in range(1,lenn): temp_min = min(minn,arr[i]) temp_max = max(maxx,arr[i]) if temp_min <minn: count+=1 minn = temp_min elif temp_max>maxx: count+=1 maxx = temp_max print(count)
7
PYTHON3
n = int(input()) ls = list(map(int, input().split(" "))) count = 0 min_ref = ls[0] max_ref = ls[0] for i in range(1, n): if min_ref > ls[i]: min_ref = ls[i] count += 1 elif max_ref < ls[i]: max_ref = ls[i] count += 1 print(count)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split(' ')] min, max = a[0], a[0] s = 0 for x in a[1:]: if x > max: max = x s += 1 elif x < min: min = x s += 1 print(s)
7
PYTHON3
n=int(input()) p=[int(i) for i in input().split()] a=0 for i in range(1,n): l=[0]*i for k in range(i): l[k]=p[k] if p[i]>max(l): a+=1 if p[i]<min(l): a+=1 print(a)
7
PYTHON3
aa = int(input()) a = list(map(int, input().split())) sum = 0 c = a[0] d = a[0] i = 0 for i in range(len(a)): if a[i] > c: sum += 1 c = a[i] i += 1 elif a[i] < d: sum += 1 d = a[i] i += 1 else: i += 1 print(sum)
7
PYTHON3
n=int(input()) a=input().split() mi=int(a[0]) ma=int(a[0]) kol=0 for elem in a: if int(elem)>ma: kol+=1 ma=int(elem) elif int(elem)<mi: kol+=1 mi=int(elem) print(kol)
7
PYTHON3
n=int(input()) A=[int(x)for x in input().split()] num=0 for i in range(1,n): m=min(A[0:i]) M=max(A[0:i]) if A[i]>M or A[i]<m: num+=1 print(num)
7
PYTHON3
import sys def main(): sys.stdin.readline() contests = list(map(int, sys.stdin.readline().split())) ans = []; new_min = []; new_max = [] for i in contests: ans.append(i) new_min.append(min(ans)) new_max.append(max(ans)) sys.stdout.write(f'{len(set(new_min))+len(set(new_max))-2}') if __name__ == '__main__': main()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, a[10000], i, sum = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } int maxv = a[0]; int minv = a[0]; for (i = 1; i < n; ++i) { if (maxv < a[i]) { maxv = a[i]; sum++; } else if (minv > a[i]) { minv = a[i]; sum++; } } printf("%d\n", sum); }
7
CPP
n = input() p = input() performance_list = p.split() performance_list = [ int(x) for x in performance_list ] count = 0 max = performance_list[0] min = performance_list[0] for i in performance_list: if i>max: max = i count += 1 if i<min: min = i count += 1 print(count)
7
PYTHON3
n = int(input()) points = list(map(int, input().split(' '))) count = 0 for i in range(len(points)-1): point_list = points[: i + 2] new_point = point_list[-1] if new_point > max(point_list[:-1]) or new_point < min(point_list[:-1]): count += 1 print(count)
7
PYTHON3
n = int(input()) a = list(map(int,input().split())) k = [] k.append(a[0]) cn = 0 for i in range(1,n): if a[i] > max(k) or a[i] < min(k): cn += 1 k.append(a[i]) print(cn)
7
PYTHON3
n = int(input()) c = map(int,input().split()) d = [] count = 0 for i in c: if i not in d: d.append(i) if max(d)==i: count =count+1 elif min(d)==i: count = count+1 print (count-1)
7
PYTHON3
input() a=[int(i) for i in input().split()] max,min=a[0],a[0] a.pop(0) ans=0 while a: score=a.pop(0) if score<min: ans+=1 min=score elif score>max: ans+=1 max=score print(ans)
7
PYTHON3