solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
n = int(input()) arr = [int(ch) for ch in input().split(' ')] min = -1 max = -1 cnt = 0 for i in range(len(arr)): if i == 0: min = arr[i] max = arr[i] continue if min > arr[i]: cnt+=1 min = arr[i] if max < arr[i]: cnt+=1 max = arr[i] print(cnt)
7
PYTHON3
num = int(input()) inputStr = list(map(int, input().split())) res = 0 i = 0 for value in inputStr: i += 1 if(i > 1 and (minValue > min(inputStr[:i]) or maxValue < max(inputStr[:i]))): res += 1 minValue = min(inputStr[:i]) maxValue = max(inputStr[:i]) print(res)
7
PYTHON3
x = int(input()) y = [int(_) for _ in input().split()] a , b , d = 10000 , 0 , 0 for i in range(x): if y[i]>b or y[i]<a: d+=1 a = min(a,y[i]) b = max(b,y[i]) print(d-1)
7
PYTHON3
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC optimize("no-stack-protector,fast-math") using namespace std; double PI = 3.1415926535897; const int N = 1e5 + 5, M = 1e2 + 5, MOD = 1e9 + 7, inf = 0x3f3f3f3f; int n, ans, mn = 1e9 + 5, mx = -1e9 + 5, ar[N], cnt[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", ar + i); for (int i = 0; i < n; i++) { if (i == 0) mx = ar[i], mn = ar[i]; if (mx < ar[i]) { ans++; mx = ar[i]; } if (mn > ar[i]) { ans++; mn = ar[i]; } } printf("%d\n", ans); return 0; }
7
CPP
def amazing(list1): count = 0 for i in range(1, len(list1)): if list1[i] > max(list1[:i]): count += 1 else: if list1[i] < min(list1[:i]): count += 1 return count n = int(input()) s = input() k = list(map(int, s.split())) print(amazing(k))
7
PYTHON3
num = int(input()) line = [int(x) for x in input().split()] amaz = 0 for i in range(num): if i >= 1: check1 = 0 check2 = 0 for j in range(i): if line[i] > line[j]: check1 += 1 elif line[i] < line[j]: check2 += 1 if check1 == i or check2 == i: amaz += 1 print(amaz)
7
PYTHON3
n = int(input()) j = list(map(int, input().split())) t = 0 max = j[0] min = j[0] for i in range(1, n): if max > j[i]: max = j[i] t += 1 elif min < j[i]: min = j[i] t += 1 print(t)
7
PYTHON3
n = int(input()) s = list(map(int, input().split(' '))) udi = 0 min = max = s[0] for i in range(1, n): if s[i] > max: max = s[i] udi += 1 elif s[i] < min: min = s[i] udi += 1 print(udi)
7
PYTHON3
n=int(input("")) arr=list(map(int,input().split())) max=arr[0]; min=arr[0]; d=0; for i in arr: if i>max: d=d+1; max=i; elif i<min: d=d+1; min=i; print(d)
7
PYTHON3
n=int(input()) b=[] count2=-1 a=list(map(int,input().split(' '))) for i in range(n): count=0 count3=0 b.clear() for j in range(i): if a[i]<a[j]: b.append(0) if a[i]>a[j]: b.append(1) if a[i]==a[j]: b.append(2) for k in b: if k!=0: count+=1 if k!=1: count3+=1 if count==0 or count3==0: count2+=1 print(count2)
7
PYTHON3
x=int(input()) y=list(map(int,input().split())) c=[y[0]] d=[y[0]] t=0 for i in range(1,x): if(y[i]>max(c)): t=t+1 c.append(y[i]) for i in range(1,x): if(y[i]<min(d)): t=t+1 d.append(y[i]) print(t)
7
PYTHON3
n = int(input()) arr = list(map(int, input().split())) bestSofar = arr[0] worstSofar = arr[0] count = 0 for x in arr: if(x > bestSofar): count+=1 bestSofar = x if(x < worstSofar): count+=1 worstSofar = x print(count)
7
PYTHON3
n=int(input()) p=list(map(int,input().split())) ka=p[0] la=p[0] sa=0 for item in p[1:]: if item>ka: ka=item sa+=1 elif item<la: la=item sa+=1 else: pass print(sa)
7
PYTHON3
a = int(input()) b = list(map(int, input().split())) h = b[0] l = b[0] c =0 for i in b[1:]: if i < l: c+=1 l = i if i > h: c += 1 h = i print(c)
7
PYTHON3
n=int(input()) arr=[] ar=list(map(int,input().split())) c=0 arr.append(ar[0]) for i in range(1,n): b=ar[i] arr.append(b) if(max(arr)==b ): if(arr.count(b)==1): c+=1 elif(min(arr)==b): if(arr.count(b)==1): c+=1 print(c)
7
PYTHON3
""" ____ _ _____ / ___|___ __| | ___| ___|__ _ __ ___ ___ ___ | | / _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __| | |__| (_) | (_| | __/ _| (_) | | | (_| __/\__ \ \____\___/ \__,_|\___|_| \___/|_| \___\___||___/ """ """ β–‘β–‘β–ˆβ–ˆβ–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–ˆβ–ˆ β–‘β–„β–€β–‘β–ˆβ–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–ˆβ–‘β–‘β–ˆβ–‘ β–‘β–ˆβ–‘β–„β–‘β–ˆβ–„β–‘β–‘β–‘β–‘β–‘β–‘β–„β–ˆβ–‘β–„β–‘β–ˆβ–‘ β–‘β–ˆβ–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„β–ˆβ–‘ β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–€β–ˆβ–ˆβ–ˆβ–ˆβ–€β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘ β–„β–ˆβ–€β–ˆβ–€β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–€β–€β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–‘β–‘β–€β–ˆβ–ˆβ–ˆβ–ˆβ–€β–€β–ˆβ–ˆβ–ˆβ–ˆβ–€β–‘β–‘β–ˆβ–ˆ β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–€β–‘β–‘β–‘β–‘β–€β–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–ˆβ–ˆβ–ˆ β–‘β–€β–ˆβ–ˆβ–ˆβ–„β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–„β–ˆβ–ˆβ–ˆβ–€β–‘ β–‘β–‘β–‘β–€β–ˆβ–ˆβ–„β–‘β–€β–ˆβ–ˆβ–€β–‘β–„β–ˆβ–ˆβ–€β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–‘β–‘β–‘β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ """ import sys import math import collections from collections import deque #sys.stdin = open('input.txt', 'r') #sys.stdout = open('output.txt', 'w') from functools import reduce from sys import stdin, stdout, setrecursionlimit setrecursionlimit(2**20) def factors(n): return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))) # for _ in range(int(stdin.readline())): n = int(stdin.readline().strip('\n')) # b = str(stdin.readline().strip('\n')) # n, m = list(map(int, stdin.readline().split())) #s = list(stdin.readline().strip('\n').split('+')) # n = len(a) #k = int(stdin.readline().strip('\n')) #a, b = 0, 0 #ans = -1 a = list(map(int, stdin.readline().split())) mn, mx = a[0], a[0] ans = 0 for i in range(n): if a[i] > mx: ans += 1 mx = a[i] if a[i] < mn: ans += 1 mn = a[i] print(ans)
7
PYTHON3
n = int(input()) lst = list(map(int,input().split())) count = 0 for i in range(1,n): if(lst[i] not in lst[0:i]): if lst[i] == min(lst[0:i+1]) or lst[i] == max(lst[0:i+1]): count+=1 print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) c=0 for i in range(1,n): a=l[:i+1] #print(a) if l[i]==max(a) or l[i]==min(a): if(a.count(l[i])!=1): c-=1 c+=1 #print(c) print(c)
7
PYTHON3
nc = int(input()) scores = input() counter = 0 sclist = scores.split() #split coverts into list for i in range(0,nc): sclist[i] = int(sclist[i]) mini=0 maxi=0 for i in range(1,nc): if(sclist[i]>sclist[maxi]): maxi = i counter += 1 elif(sclist[i]<sclist[mini]): mini = i counter += 1 print(counter)
7
PYTHON3
try: n=int(input()) arr=list(map(int,input().split())) maxele=arr[0] minele=arr[0] c=0 for i in range(len(arr)): if arr[i]>maxele: maxele=arr[i] c+=1 if arr[i]<minele: minele=arr[i] c+=1 print(c) except EOFError: pass
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) if n==1: print(0) else: ma=l[0] mi=l[0] c,cf=0,0 for i in range(n): if ma<l[i]: c=c+1 ma=l[i] if mi>l[i]: cf=cf+1 mi=l[i] print(c+cf)
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] if n==1: print(0) else: if l[0]==l[1]: m=0 else: m=1 k=[] k.append(l[0]) k.append(l[1]) for i in range(2,len(l)): if min(k)<=l[i]<=max(k): pass else: m+=1 k.append(l[i]) print(m)
7
PYTHON3
n = int(input()) p = [int(s) for s in input().split(' ')] run_min = p[0] run_max = p[0] count = 0 for s in p[1:]: if s < run_min: count += 1 run_min = s elif s > run_max: count += 1 run_max = s print(count)
7
PYTHON3
no_of_matches=int(input()) list_of_scores=list(map(int,input().split(' '))) min=max=list_of_scores[0] amazing_performances=0 for i in list_of_scores[1:]: if(i>max): max=i amazing_performances=amazing_performances+1 elif(i<min): min=i amazing_performances=amazing_performances+1 print(amazing_performances)
7
PYTHON3
n=int(input()) a=input().split() a=[int(i) for i in a] maxlist=a[0] minlist=a[0] amazing=0 for i in range (1,len(a)): if a[i]>maxlist: maxlist=a[i] amazing+=1 if a[i]<minlist: minlist=a[i] amazing+=1 print(amazing)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) len = len(a) min = a[0] max = a[0] count = 0 for i in range(0,len-1): if a[i+1] > a[i]: if a[i+1] > max: max = a[i+1] count = count + 1 elif a[i+1] < a[i]: if a[i+1] < min: min = a[i+1] count = count + 1 print(count)
7
PYTHON3
n = int(input()) data = [int(i) for i in input().split()] mini = maxi = data[0] cnt = 0 for x in data[1:]: if x < mini: cnt += 1 mini = x elif x > maxi: cnt += 1 maxi = x print(cnt)
7
PYTHON3
n = int(input()) s = list(map(int, input().split())) max_score, min_score = s[0], s[0] answer = 0 for i in s[1:]: if i > max_score: answer += 1 max_score = i if i < min_score: answer += 1 min_score = i print(answer)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) if n==1: print('0') else: if a[0]==a[1]: ans=0 if a[0]!=a[1]: ans=1 for i in range(2,n): if a[i]> max(a[:i]) or a[i]< min(a[:i]): ans+=1 print(ans)
7
PYTHON3
import sys import math # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') def solve(): n = int(input()) a = [int(x) for x in input().split()] max_val, min_val = a[0], a[0] ans = 0 for i in range(1, n): if a[i] > max_val: max_val = a[i] ans += 1 elif a[i] < min_val: min_val = a[i] ans += 1 print(ans) if __name__ == "__main__": test_cases = 1 for _ in range(test_cases): solve()
7
PYTHON3
t = int(input()) nums = list(map(int, input().split())) lowest = nums[0] highest = nums[0] count = 0 for i in range(1, t): if lowest > nums[i]: count += 1 lowest = nums[i] elif nums[i] > highest: count += 1 highest = nums[i] print(count)
7
PYTHON3
c=0 n=int(input()) a=[int(i) for i in input().split()] m,b=a[0],a[0] for i in a: if i<m: c+=1 m=i if i>b: c+=1 b=i print(c)
7
PYTHON3
n=int(input()) d=[int(i) for i in input().split()] mx=d[0] mi=d[0] s=0 for i in range(n): if d[i]>mx: mx=d[i] s+=1 elif d[i]<mi: mi=d[i] s+=1 print(s)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) best=l[0] worst=l[0] s=0 for i in range(1,len(l)): if l[i]<worst: s+=1 worst=l[i] if l[i]>best: s+=1 best=l[i] print(s)
7
PYTHON3
n = int(input()) l = list(map(int,input().split())) c=0 for i in range(1,n): if l[i] > max(l[0:i]) or l[i] < min(l[0:i]): c+=1 print(c)
7
PYTHON3
import sys n = int(input()) numbers = list(map(int, input().split())) sum_numbers = 0 index = 0 max_value = 0 min_value = 0 while(index < n): #print(index) if(index == 0): max_value = numbers[index] min_value = numbers[index] else: if(numbers[index] > max_value): sum_numbers += 1 max_value = numbers[index] if(numbers[index] < min_value): sum_numbers += 1 min_value = numbers[index] index +=1 print(sum_numbers)
7
PYTHON3
n = int(input()) contest = list(map(int,input().split())) count = 0 for i in range(1,len(contest)): if contest[i] > max(contest[:i]) or contest[i] < min(contest[:i]): count += 1 print(count)
7
PYTHON3
x=int(input()) s=input().split() k=0 s=list(map(int,s)) for i in range(1,x): t=s[:i] a=max(t) b=min(t) if s[i]>a or s[i]<b: k=k+1 print(k)
7
PYTHON3
n=int(input()) x=input().split() x=[int(x[i])for i in range(n)] t=0 for i in range(1,n): u,v=0,0 for j in range(i+1): if x[i]>x[j]: u+=1 elif x[i]<x[j]: v+=1 if u==i or v==i: t+=1 print(t)
7
PYTHON3
n = int(input()) lis = list(map(int, input().split())) if len(lis) == 1 or (len(lis) == 2 and lis[0] == lis[1]): print(0) elif len(lis) == 2 and lis[0] != lis[1]: print(1) else: highest = max(lis[0:2]) lowest = min(lis[0:2]) amazing = int(bool(lis[0] != lis[1])) for i in range(2, n): if lowest <= lis[i] <= highest: continue else: lowest = min(lis[i], lowest) highest = max(lis[i], highest) amazing = amazing+1 print(amazing)
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] a=l[0] b=l[0] k=0 for i in range(1,n): if(l[i]<a): a=l[i] k=k+1 if(l[i]>b): b=l[i] k=k+1 print(k)
7
PYTHON3
n=int(input()) lst=list(map(int,input().split())) min,max=lst[0],lst[0] cnt=0 for i in range(1,n): if lst[i]<min: min=lst[i] cnt+=1 elif lst[i]>max: max=lst[i] cnt+=1 print(cnt)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, nums, sum = 0; vector<int> v; cin >> n; for (int i = 0; i < n; i++) { cin >> nums; v.emplace_back(nums); } int min = v[0]; int max = v[0]; for (int i = 0; i < n; i++) { if ((v[i] > max)) { max = v[i]; sum++; } else if (v[i] < min) { min = v[i]; sum++; } } cout << sum << '\n'; return 0; }
7
CPP
n = int(input()) arr = [int(i) for i in input().split(' ')] res = 0 for i in range( 1,len(arr) ): maxi, mini = 0,0 for j in range(i): if(arr[i] > arr[j]): maxi+=1 if(arr[i] < arr[j]): mini+=1 if(maxi == i or mini == i): res+=1 print(res)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) max=a[0] min=a[0] count=0 for i in range(1,n): if a[i]>max: max=a[i] count+=1 elif a[i]<min: min=a[i] count+=1 print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n; int inp; int ac = 0; int more = 0; int less = 0; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) { cin >> inp; arr[i] = inp; } for (int j = 1; j < n; ++j) { for (int k = 0; k < j; ++k) { if (arr[k] > arr[j]) { more++; } else if (arr[k] < arr[j]) { less++; } else if (arr[k] == arr[j]) { more++; less++; } } if (!(more != 0 && less != 0)) { ac++; } more = 0; less = 0; } cout << ac; return 0; }
7
CPP
n=int(input()) c=0 l=list(map(int,input().split())) lo=l[0] hg=l[0] for i in range(1,n): if l[i] < lo: c+=1 lo=l[i] elif l[i] > hg: c+=1 hg=l[i] print(c)
7
PYTHON3
num_contest = int(input()) lst_point = list(map(int, input().split())) max_point = lst_point[0] min_point = lst_point[0] amazing_time = 0 for point in lst_point: if point > max_point: amazing_time += 1 max_point = point elif point < min_point: amazing_time += 1 min_point = point print(amazing_time)
7
PYTHON3
def solve(): n = int(input()) cl = list(map(int, input().split())) fi = True amz = 0 ma = 0 mi = 0 for i in cl: if fi: ma = i mi = i fi = False continue if i > ma: amz += 1 ma = i elif i < mi: amz += 1 mi = i print(amz) if __name__ == '__main__': solve()
7
PYTHON3
n= int(input()) A=list(map(int,input().split())) mx=A[0] mn=A[0] if n==1: print(0) else: cnt=0 for j in range(1,n): if A[j]>mx: cnt+=1 mx=A[j] elif A[j]<mn: cnt+=1 mn=A[j] print(cnt)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; bool check(int n1) { vector<int> d(10, 0); while (n1) { d[n1 % 10]++; n1 = n1 / 10; } for (auto &x : d) { if (x > 1) return false; } return true; } void solve() { int n; cin >> n; int a; cin >> a; int m1 = a, m2 = a; int res = 0; for (int i = 1; i < n; i++) { int x; cin >> x; if (x > m1) { res++; m1 = x; } if (x < m2) { res++; m2 = x; } } cout << res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); return 0; }
7
CPP
input() data = list(map(int, input().split())) mx = mn = data[0] res = 0 for v in data[1:]: if v < mn: res += 1 mn = v elif v > mx: res += 1 mx = v print(res)
7
PYTHON3
x=int(input()) arr=list( map( int,input().split() ) ) w=b=arr[0] ans=0 for i in range(1,x): if arr[i]>b: b=arr[i] ans+=1 elif arr[i]<w: w=arr[i] ans+=1 print(ans)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) mn=arr[0] mx=arr[0] ans=0 for i in range(1,n): if(arr[i]>mx): mx=arr[i] ans+=1 if(arr[i]<mn): mn=arr[i] ans+=1 print(ans)
7
PYTHON3
n=int(input()) m=[int(i) for i in input().split()] a=m[0] b=m[0] exc=0 for i in range(1,n): if m[i]>a: a=m[i] exc+=1 elif m[i]<b: b=m[i] exc+=1 print(exc)
7
PYTHON3
input() count=0 x=list(map(int,input().split())) for i in range(1,len(x)): if(x[i]<min(x[0:i]) or x[i]>max(x[0:i])): count+=1 print(count)
7
PYTHON3
q = int(input()) s = list(map(int, input().split())) mi = s[0] ma = s[0] need = 0 for i in range(len(s)): if s[i] > ma: need += 1 ma = s[i] elif s[i] < mi: need += 1 mi = s[i] print(need)
7
PYTHON3
n=int(input()) ar=list(map(int,input().split())) m=ar[0] M=ar[0] per=0 for x in ar[1:]: if(x<m): per=per+1 m=x elif(x>M): per=per+1 M=x print(per)
7
PYTHON3
n = input() a = input().split(' ') for i in range(0,len(a)): a[i] = int(a[i]) mx = a[0] mn = a[0] cnt = 0 for i in range(1,len(a)): if a[i] > mx: mx = a[i] cnt += 1 if a[i] < mn: mn = a[i] cnt += 1 print(cnt)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; for (int i = 0; i < n; i++) { int num; cin >> num; a.push_back(num); } int maxm = a[0]; int minm = a[0]; int c = 0; for (int i = 1; i < n; i++) { if (a[i] > maxm) { maxm = a[i]; c++; } if (a[i] < minm) { minm = a[i]; c++; } } cout << c; }
7
CPP
n=int(input()) a=input().split() l=[] if len(a)==1: print(0) else: l.append(int(a[0])) l.append(int(a[1])) if l[0]==l[1]: sum=0 else: sum=1 for i in range(2,n): if int(a[i])>max(l) or int(a[i])<min(l): sum+=1 l.append(int(a[i])) print(sum)
7
PYTHON3
n = int(input()) l = list(map(int,input().split()))[:n] if n == 1: count = 0 else: mi = l[0] ma = l[0] count = 0 for i in range(1 , n): if l[i] > ma: count += 1 ma = l[i] if l[i] < mi: count += 1 mi = l[i] print(count)
7
PYTHON3
n=int(input()) p=list(map(int,input().split())) best_record=worst_record=p[0] amazing=0 for i in p[1:]: if i>best_record: best_record=i amazing+=1 elif i<worst_record: worst_record=i amazing+=1 print(amazing)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, l = 0, j = 0, k = 0; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } j = arr[0]; k = arr[0]; for (int i = 0; i < n; i++) { if (arr[i] < j) { j = arr[i]; l++; } else if (arr[i] > k) { k = arr[i]; l++; } } cout << l; return 0; }
7
CPP
n = int(input()) k = [int(j) for j in input().split()] a = k[0] b = k[0] s = 0 for i in range(len(k)): if k[i] > a: s += 1 a = k[i] elif k[i] < b: s += 1 b = k[i] else: pass print(s)
7
PYTHON3
n = int(input()) raw = [int(x) for x in input().split(' ')] max = raw[0] min = raw[0] s = 0 for i in range(1,n): if raw[i]>max: s+=1 max = raw[i] elif raw[i]<min: s+=1 min = raw[i] print(s)
7
PYTHON3
n=int(input()) a=[int(x) for x in input().split()] min_a=max_a=a[0] c=0 for i in range(1,n): if(a[i]<min_a): min_a=a[i] c+=1 elif(a[i]>max_a): max_a=a[i] c+=1 print(c)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) v=0 b=[l[0]] for i in range(1,n): if(l[i]<min(b) or l[i]>max(b)): v=v+1 b.append(l[i]) print(v)
7
PYTHON3
n=int(input()) l=input().split() m=int(l[0]) ma=int(l[0]) ans=0 for i in range(1,n): if int(l[i])>ma or int(l[i])<m: ans+=1 if m>int(l[i]): m=int(l[i]) if ma<int(l[i]): ma=int(l[i]) print(ans)
7
PYTHON3
n=int(input()) po=[int(t) for t in input().split()] point=[] for i in po: if i not in point: point.append(i) if len(point)<2: print(0) exit() else: M=max(point[0],point[1]) m=min(point[0],point[1]) value=1 for i in range(2,len(point)): if point[i]>M: M=point[i] value+=1 elif point[i]<m: m=point[i] value+=1 print(value)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) c_1=0 for i in range(1,n): j=i-1 if l[i]>l[j]: while(j>=0 and l[i]>l[j]): j=j-1 if j==-1: c_1=c_1+1 elif l[i]<l[j]: while(j>=0 and l[i]<l[j]): j=j-1 if j==-1: c_1=c_1+1 print(c_1)
7
PYTHON3
input() scores = input() scoresList = scores.split() biggest = None smallest = None amazing = 0 count = 0 for i in scoresList: if count == 0: biggest = int(i) smallest = int(i) if count != 0: if int(i) > biggest: biggest = int(i) amazing += 1 if int(i) < smallest: smallest = int(i) amazing += 1 count += 1 print(amazing)
7
PYTHON3
# -*- coding: utf-8 -*- """ Created on Sat Jan 12 13:13:58 2019 @author: nishantwrp """ n = int(input()) a = list(map(int,input().split())) mina = a[0] maxa = a[0] ans = 0 for i in range(1,n): if a[i] > maxa: ans += 1 maxa = a[i] elif a[i] < mina: ans += 1 mina = a[i] print(ans)
7
PYTHON3
def main(): n = int(input()) a = list(map(int, input().split())) ans = 0 mx = mn = a[0] for i in range(1, n): if a[i] > mx: ans += 1 mx = a[i] if a[i] < mn: ans += 1 mn = a[i] print(ans) pass if __name__ == '__main__': main()
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int mostFrequent(int arr[], int n) { sort(arr, arr + n); int max_count = 1, res = arr[0], curr_count = 1; for (int i = 1; i < n; i++) { if (arr[i] == arr[i - 1]) curr_count++; else { if (curr_count > max_count) { max_count = curr_count; res = arr[i - 1]; } curr_count = 1; } } if (curr_count > max_count) { max_count = curr_count; res = arr[n - 1]; } return max_count; } vector<int> factors(int n) { vector<int> f; for (int x = 2; x * x <= n; x++) { while (n % x == 0) { f.push_back(x); n /= x; } } if (n > 1) f.push_back(n); return f; } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int c = 0; int max = a[0]; for (int i = 1; i < n; i++) { if (a[i] > max) { max = a[i]; c++; } } int min = a[0]; for (int i = 1; i < n; i++) { if (a[i] < min) { min = a[i]; c++; } } if (n > 1) cout << c << endl; else cout << "0" << endl; return 0; }
7
CPP
def Amazing(arr): Max=arr[0] Min=arr[0] amazing=0 for i in range (1 , n): if arr[i]>Max: Max=arr[i] amazing+=1 if arr[i]<Min: Min=arr[i] amazing+=1 return amazing n=int(input()) Contests=list(map(int , input().split())) print(Amazing(Contests))
7
PYTHON3
n=int(input()) lis=input().split() for i in range(n): lis[i]=int(lis[i]) m=lis[0] M=lis[0] c=0 if n==1: print('0') else: for i in range(1,n): if lis[i]>M or lis[i]<m: c+=1 if lis[i]>M: M=lis[i] else: m=lis[i] print(c)
7
PYTHON3
n = int(input()) l = list(map(int,input().split())) mx = l[0] mn = l[0] ans = 0 for i in l[1:]: if(mn > i): ans += 1 mn = i elif(mx < i): ans += 1 mx = i print(ans)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) min=arr[0] max=arr[0] count=0 for i in range(1,n): if arr[i]<min: min=arr[i] count+=1 elif arr[i]>max: max=arr[i] count+=1 print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, i = 1; int ma = 0, mi = 0, y = 0; cin >> n; int a[n]; cin >> a[0]; ma = a[0]; mi = a[0]; while (i < n) { cin >> a[i]; if (ma == a[i] || mi == a[i]) { i++; } else { ma = max(ma, a[i]); if (ma == a[i]) { y++; } mi = min(mi, a[i]); if (mi == a[i]) { y++; } i++; } } cout << y; }
7
CPP
def main(): n=int(input()) list1=list(map(int,input().split(" "))) min1=list1[0] max1=list1[0] c=0 for i in range(n-1): if list1[i+1]>max1: max1=list1[i+1] c+=1 elif list1[i+1]<min1: min1=list1[i+1] c+=1 else: pass print(c) main()
7
PYTHON3
n=int(input()) min=0 max=0 sum=0 l=input().split() for i in range(n): if(i==0): min=int(l[i]) max=int(l[i]) else: if(int(l[i])>max): max=int(l[i]) sum+=1 elif(int(l[i])<min): min=int(l[i]) sum+=1 print(sum)
7
PYTHON3
from sys import stdin,stdout inp = stdin.readline out = stdout.write n = int(inp().strip()) a = list(map(int,inp().strip().split())) mx,mn,c=a[0],a[0],0 for i in range(1,n): if a[i]>mx: c+=1 mx=a[i] elif a[i]<mn: c+=1 mn=a[i] print(c)
7
PYTHON3
totalpoints=int(input()) answer=0 points=[int(i) for i in input().split()] prevmax,premin=points[0],points[0] for i in range(2,len(points)+1): a=points[0:i] if(premin>min(a)): premin=min(a) answer+=1 elif(prevmax<max(a)): prevmax=max(a) answer+=1 print(answer)
7
PYTHON3
x=int(input()) y=list(map(int,input().split())) d=0 for i in range (1,x): if y[i]<min(y[:i]) or y[i]>max(y[:i]): d+=1 print(d)
7
PYTHON3
n = int(input()) line = input().split() max = int(line[0]) min = int(line[0]) ans = 0 for i in line[1:]: if int(i) > max: max = int(i) ans += 1 if int(i) < min: min = int(i) ans += 1 print(ans)
7
PYTHON3
if __name__ == "__main__": n = int(input()) scores = list(map(int , input().rstrip().split())) maxScore = scores[0] minScore = scores[0] count = 0 for i in range(1 , len(scores)): if scores[i] > maxScore: maxScore = scores[i] count += 1 continue if scores[i] < minScore: minScore = scores[i] count += 1 print (count)
7
PYTHON3
n = int(input()) m = input().split() count = 0 c = 0 my_list = [] for i in range(n): c += 1 my_list.append(int(m[i])) x = my_list.count(int(m[i])) if max(my_list) == int(m[i]) and c > 1 and x < 2: count += 1 elif min(my_list) == int(m[i]) and c > 1 and x < 2: count += 1 print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) m=l[0] n=l[0] count=0 for i in l: if i>m: m=i count=count+1 if i<n: count=count+1 n=i print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) count=0 for i in range(1,len(l)): if(l[i]<min(l[:i]) or l[i]>max(l[:i])): count+=1 print(count)
7
PYTHON3
n =int(input()) k = list(map(int, input().split())) z = list() c =list() for i in range(1, len(k)): c.append(k[i -1]) e = max(c) d = min(c) if k[i - 1] <k [i] and k[i] >e or k[i] <d: if k[i] not in z: z.append(k[i]) if n ==1: print(0) else: print(len(z))
7
PYTHON3
n = int(input()) s = input().split() s = [int(x) for x in s] amazing = 0 if n == 1: print(0) elif n == 2: if s[1] > s[0] or s[1] < s[0]: print(1) else: print(0) else: if s[1] > s[0] or s[1] < s[0]: amazing += 1 for i in range(2,n): if s[i] > max(s[:i]) or s[i] < min(s[:i]): amazing += 1 print(amazing)
7
PYTHON3
n = int(input()) a = *map(int, input().split()), print(sum(a[i] < min(a[:i]) or a[i] > max(a[:i]) for i in range(1, n)))
7
PYTHON3
n = int(input()) scores = list(map(int, input().split())) count = 0 low = scores[0] high = scores[0] for i in range(1, n): score = scores[i] count += int(score < low) low = min(low, score) count += int(score > high) high = max(high, score) print (count)
7
PYTHON3
def solve(n, a): mini = a[0] maxi = a[0] x = 0 for i in a[1:]: if i < mini: x += 1 mini = min(mini, i) elif i > maxi: x += 1 maxi = max(maxi, i) return x def main(): n = int(input()) a = list(map(int, input().split())) print(solve(n, a)) main()
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) s=l[0] r=l[0] q=0 for i in range(1,n): if l[i]>s: s=l[i] q=q+1 elif l[i]<r: r=l[i] q=q+1 print(q)
7
PYTHON3
a=int(input()) b=list(map(int,input().split(" "))) c=b[0] max=c min=c count=0 for i in range(1,a): if b[i]>max: max=b[i] count=count+1 elif b[i]<min: min=b[i] count=count+1 print(count)
7
PYTHON3
n = int(input()) a = list(map(int,input().split())) maxval = minval = a[0] count = 0 for i in a: if i > maxval: maxval = i count += 1 elif i < minval: minval = i count += 1 print(count)
7
PYTHON3
input() numbers = list(map(int, input().split())) small, big = numbers[0], numbers[0] c = 0 for number in numbers: if number < small: c+=1 small = number elif number > big: c+=1 big = number print(c)
7
PYTHON3
a=int(input()) s=input().split() n=0 for i in range(0,a): s[i]=int(s[i]) for i in range(1,a): if s[i]>max(s[0:i]) or s[i]<min(s[0:i]): n+=1 print(n)
7
PYTHON3