solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
n = int(input()) a = list(map(int, input().split())) mx, mn = a[0], a[0] ans = 0 for i in range(1, n): if a[i] > mx or a[i] < mn: ans += 1 mn, mx = min(mn, a[i]), max(mx, a[i]) print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, maxx, minn, y = 0, a; scanf("%d", &n); scanf("%d", &maxx); minn = maxx; n--; while (n--) { scanf("%d", &a); if (a > maxx) { maxx = a; y++; } if (a < minn) { minn = a; y++; } } printf("%d", y); }
7
CPP
n=int(input()) li=[int(x) for x in input().split()] ncount=0 ll=[li[0]] for num in li: if num>max(ll) or num<min(ll): ncount+=1 ll.append(num) print(ncount)
7
PYTHON3
n = int(input()) rez = list(map(int, input('').split())) count_rez = 0 for i in range(len(rez)): if i == 0: rez_max, rez_min = rez[0], rez[0] if i != 0 and rez[i] > rez_max: rez_max = rez[i] count_rez += 1 elif i != 0 and rez[i] < rez_min: rez_min = rez[i] count_rez += 1 print(count_rez)
7
PYTHON3
n=int(input()) list1=input().split() s=0 max1=min1=int(list1[0]) for i in range(n): list1[i]=int(list1[i]) if list1[i]>max1: s+=1 max1=list1[i] if list1[i]<min1: s+=1 min1=list1[i] print(s)
7
PYTHON3
n = int(input()) ls = list(map(int, input().split())) mn = ls[0] cnt = 0 mx = ls[0] for i in range(1, n): f = False if ls[i] > mx: mx = ls[i] f = True if ls[i] < mn: mn = ls[i] f = True if f: cnt += 1 print(cnt)
7
PYTHON3
a=int(input()) k=0 b=input().split() min=int(b[0]) max=int(b[0]) for i in range(1,a): if int(b[i])>max: max=int(b[i]) k+=1 elif int(b[i])<min: min=int(b[i]) k+=1 print(k)
7
PYTHON3
# 155A input() a = [int(i) for i in input().split()] Max = a[0] Min = a[0] Cnt = 0 for rec in a: if rec>Max or rec<Min: Max = max(Max,rec) Min = min(Min,rec) Cnt += 1 print(Cnt)
7
PYTHON3
def contest(values): maximum=float('-inf') minimum=float('inf') count_max=-1 count_min=-1 for i in range(len(values)): if values[i]>maximum: count_max=count_max+1 maximum=values[i] if values[i]<minimum: count_min=count_min+1 minimum=values[i] return count_max+count_min n=int(input()) values=list(map(int,input().split())) print(contest(values))
7
PYTHON3
input() l = [int(x) for x in input().split()] Min = l[0] Max = l[0] ans = 0 for x in l[1:]: if x < Min: ans += 1 Min = x if x > Max: ans += 1 Max = x print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(void) { int n; int temp; cin >> n; cin >> temp; int ans = 0; int MAX_ele = temp; int MIN_ele = temp; for (int i = 1; i < n; ++i) { cin >> temp; if (temp > MAX_ele) { ans++; MAX_ele = temp; } if (temp < MIN_ele) { ans++; MIN_ele = temp; } } cout << ans << endl; return 0; }
7
CPP
n=int(input()) l=[int(i) for i in input().split()] max=l[0] min=l[0] sum=0 for i in range(n): if l[i]>max : max=l[i] sum+=1 elif l[i]<min: min=l[i] sum+=1 print(sum)
7
PYTHON3
n = int(input()) a = input().split() min = int(a[0]) max = int(a[0]) x = 0 for i in range(1 , n): a[i] = int(a[i]) if a[i] > max: x += 1 max= a[i] if a[i] < min: x += 1 min = a[i] print(x)
7
PYTHON3
def func(arr, n): cnt = 0 high = low = arr[0] for i in range(1, n): if(high < arr[i]): high = arr[i] cnt += 1 if(low > arr[i]): low = arr[i] cnt += 1 return cnt n = int(input()) arr = list(map(int, input().split())) print(func(arr, n))
7
PYTHON3
n = int(input()) l = list(map(int, input().split())) b = l[0] w = l[0] t = 0 for i in l: if i < w: w = i t += 1 if i > b: b = i t += 1 print(t)
7
PYTHON3
x = int(input("")) Min = -1 Max = -1 total = 0 y = input("").split() for i in range(x): y[i] = int(y[i]) for i in range(x): if(Max == -1): Max = y[i] Min = y[i] if(y[i] > Max): total += 1 Max = y[i] elif(y[i] < Min): total += 1 Min = y[i] print(total)
7
PYTHON3
n = int(input()) case = list(map(int,input().split())) count = 0 maxi = case[0] mini = case[0] for i in range(1,len(case)): if case[i] > maxi: maxi = case[i] count+=1 if case[i] < mini: mini = case[i] count+=1 print(count)
7
PYTHON3
def main(): n = int(input()) games = [int(i) for i in input().split(" ")] rez_min = None rez_max = None amz = 0 for game in games: if rez_min == None and rez_max == None: rez_min = game rez_max = game else: if game < rez_min or game > rez_max: rez_min = min(rez_min, game) rez_max = max(rez_max, game) amz += 1 print(amz) if __name__ == "__main__": main()
7
PYTHON3
import sys import math import bisect from sys import stdin,stdout from math import gcd,floor,sqrt,log from collections import defaultdict as dd from bisect import bisect_left as bl,bisect_right as br sys.setrecursionlimit(100000000) ii =lambda: int(input()) si =lambda: input() jn =lambda x,l: x.join(map(str,l)) sl =lambda: list(map(str,input().strip())) mi =lambda: map(int,input().split()) mif =lambda: map(float,input().split()) lii =lambda: list(map(int,input().split())) ceil =lambda x: int(x) if(x==int(x)) else int(x)+1 ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1 flush =lambda: stdout.flush() stdstr =lambda: stdin.readline() stdint =lambda: int(stdin.readline()) stdpr =lambda x: stdout.write(str(x)) mod=1000000007 #main code n=ii() arr=lii() count=0 for i in range(1,n): if arr[i]>max(arr[:i]) or arr[i]<min(arr[:i]): count+=1 print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x; cin >> x; int max = x; int min = x; int count = 0; for (int i = 1; i < n; i++) { cin >> x; if (x < min || x > max) { count++; if (x < min) { min = x; } else { max = x; } } } cout << count << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, a, min = 0, max = 0, count = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; if (i == 0) { min = max = a; } if (a > max) { max = a; count++; } if (a < min) { min = a; count++; } } cout << count; return 0; }
7
CPP
n = int(input()) POINTS = [int(x) for x in input().split()] amaze = 0 min = POINTS[0] max = POINTS[0] for i in range(1, n): if POINTS[i] < min: amaze += 1 min = POINTS[i] elif POINTS[i] > max: amaze += 1 max = POINTS[i] print(amaze)
7
PYTHON3
n = int(input()) perfomances = [int(x) for x in input().split(" ")] max = perfomances[0] min = perfomances[0] counter = 0 for performance in perfomances: if(perfomances[0] == performance): pass elif performance > max: max = performance counter += 1 elif performance < min: min = performance counter += 1 print(counter)
7
PYTHON3
a=int(input()) ch=input() l=ch.split() for i in range(len(l)): l[i]=int(l[i]) max=l[0] min=l[0] s=0 for i in range(1,a): if l[i]<min: s=s+1 min=l[i] if max<l[i]: s=s+1 max=l[i] print(s)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; clock_t TimeBegin, TimeEnd; long long const MAX = 1e18; long long const Base = 1; inline long long fpow(long long a, long long x) { if (x == 0) return 1; if (x & 1) { return a * fpow(a, x - 1) % Base; } else { long long t = fpow(a, x / 2); return t * t % Base; } } inline long long diMod(long long A, long long B) { long long result = (A * fpow(B, Base - 2)) % Base; return result; } inline void Tstart(); inline void Tstop(); long long a[1005], n, ans = 0, Max, Min; void Solve() { cin >> n; for (long long i = 0; i < (n); ++i) { cin >> a[i]; if (i == 0) { Max = a[i]; Min = a[i]; } if (a[i] > Max) { ans++; Max = a[i]; } else if (a[i] < Min) { ans++; Min = a[i]; } } cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); Solve(); return 0; } void Tstart() { TimeBegin = clock(); } void Tstop() { TimeEnd = clock(); cout << "\nTime elapsed: " << 1000 * (TimeEnd - TimeBegin) / CLOCKS_PER_SEC << " ms\n"; }
7
CPP
n=int(input()) talika=list(map(int,input().split())) talika2=[talika[0]] ping=0 for i in range(n): if max(talika2)<talika[i] or min(talika2)>talika[i]: ping+=1 talika2.append(talika[i]) else: talika2.append(talika[i]) print(ping)
7
PYTHON3
n=int(input()) nums=input().split() a=[] for i in nums: a.append(int(i)) def love(): x=0 y=0 min = a[0] max = a[0] for i in range(1,len(a)): if a[i]<min: min=a[i] x=x+1 if a[i]>min: if a[i]>max: max=a[i] y=y+1 return(x+y) print(love())
7
PYTHON3
contests=int(input()) score=list(map(int,input().split())) number=score[:1] for i in score: contests-=min(number)<=i<=max(number) number+=[i] print(contests)
7
PYTHON3
n=int(input()) mark=list(map(int,input().split())) markmax=mark[0] markmin=mark[0] performances=0 for i in range(1,n): if mark[i]>markmax: performances+=1 markmax=mark[i] if mark[i]<markmin: performances+=1 markmin=mark[i] print(performances)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) sum=0 b=[] b.append(a[0]) for i in range(n): if max(b)<a[i]: sum=sum+1 else: sum=sum if min(b)>a[i]: sum=sum+1 else: sum=sum b.append(a[i]) print(sum)
7
PYTHON3
n = int(input()) l = list(map(int, input().split())) min_val = l[0] max_val = l[0] c = 0 for i in l[1:]: if min_val < i: c += 1 min_val = i elif max_val > i: c += 1 max_val = i print(c)
7
PYTHON3
n = int(input()) li = list(map(int,input().split(' '))) if n==1: print(0) else: count = 0 for i in range(1,n): #count = 0 #print(li[i]) m = li[0] if m < li[i]: c = 0 for j in range(i): if li[j] >= li[i]: c = 1 break if c==0: # print("strictly greater") count += 1 else: c = 0 for j in range(i): if li[j] <= li[i]: c = 1 break if c==0: #print("strictly less") count += 1 print(count)
7
PYTHON3
a = int(input()) A = [int(i) for i in input().split()] ma = A[0] mi = A[0] counter = 0 for i in A[1:]: if i>ma: ma = i counter+=1 elif i<mi: mi = i counter+=1 print(counter)
7
PYTHON3
n = int(input()) s = input().split() maximum = int(s[0]) minimum = int(s[0]) count = 0 for i in range(1, n): x = int(s[i]) if x > maximum: count += 1 if x < minimum: count += 1 maximum = max(maximum, x) minimum = min(minimum, x) print(count)
7
PYTHON3
n=int(input()) list=[int(i) for i in input().split()] a=b=list[0] sum=0 for k in range(1,n): c=max(list[k],a) d=min(list[k],b) if c>a or d<b: sum+=1 else: sum+=0 a=c b=d print(sum)
7
PYTHON3
n = int(input()) L = [int(x) for x in input().split()] c = 0 for i in range(2, n+1): if max(L[:i]) > max(L[:(i-1)]) or min(L[:i]) < min(L[:(i-1)]): c += 1 print(c)
7
PYTHON3
n = int(input()) A = [int(k) for k in input().split()] output = 0 for i in range(1,n): B = A[:i+1] B.sort() if (A[i] == B[0] and A[i]!= B[1]) or (A[i] == B[i] and A[i] !=B[i-1]): output += 1 print(output)
7
PYTHON3
def coder(n, a): mini = a[0] maxi = a[0] count = 0 for i in range(1, n): if(a[i]>maxi): maxi = a[i] count += 1 elif(a[i]<mini): mini = a[i] count += 1 return count n = int(input()) a = list(map(int, input().split())) print(coder(n, a))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, a, mn, mx, ans = 0; cin >> n >> a; mn = mx = a; for (int i = 1; i < n; i++) { cin >> a; if (a < mn) { mn = a; ans++; } if (a > mx) { mx = a; ans++; } } cout << ans; }
7
CPP
A=input() num=input() numstr=num.split(' ') realnum=[int(i) for i in numstr] amazingtime=0 max=realnum[0] min=realnum[0] for i in realnum: if i>max: max=i amazingtime+=1 else: if i<min: min=i amazingtime+=1 print(amazingtime)
7
PYTHON3
a=int(input()) amaze=0 p=list(map(int,input().split())) mxa=p[0] mni=p[0] for i in range(len(p)): if p[i]>mxa: amaze+=1 mxa=p[i] elif p[i]<mni: amaze+=1 mni=p[i] print(amaze)
7
PYTHON3
if __name__ == '__main__': n = int(input()) l = list(map(int, input().split())) m, M = l[0], l[0] sol = 0 for x in l: if x < m: m = x sol += 1 elif x > M: M = x sol += 1 print(sol)
7
PYTHON3
n=int(input()) x=list(map(int,input().split())) flag=0 for i in range(n): new=[] for j in range(i+1): new.append(x[j]) #print(new) if min(new)==x[j] or max(new)==x[j]: if j!=0: if x[j] not in new[:-1]: flag=flag+1 print(flag)
7
PYTHON3
num = int(input()) x = input() a = x.split() b = [] result = 0 for x in a: b.append(int(x)) max = b[0] min = b[0] for x in b : if x < min : result += 1 min = x if x > max: result+= 1 max = x print(result)
7
PYTHON3
n = int(input()) points = [int(x) for x in input().split()] max_v, min_v = points[0], points[0] count = 0 for p in points: if p > max_v: max_v = p count += 1 elif p < min_v: min_v = p count += 1 print(count)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) t=0 mi=l[0] mx=l[0] for i in range(1,n): if l[i]<mi: t +=1 mi=l[i] elif mx<l[i]: t +=1 mx=l[i] print(t)
7
PYTHON3
n=int(input()) p = list(map(int,input().split())) low,high=[p[0],p[0]] count =0 for i in range(1,len(p)): if p[i]<low or p[i]>high: count+=1 low = min(p[:i+1]) high = max(p[:i+1]) print(count)
7
PYTHON3
N = int(input()) A = list(map(int, input().split())) max_val = A[0] min_val = A[0] count_awesome = 0 for i in range(1, N): if A[i] > max_val: max_val = A[i] count_awesome += 1 if A[i] < min_val: min_val = A[i] count_awesome += 1 print(count_awesome)
7
PYTHON3
a = int(input()) l = list(map(int,input().split())) if a<3: b = set(l) if len(b)>1:print(1) else:print(0) else: z = max(l[0],l[1]) x = min(l[0],l[1]) if z==x:c=0 else:c=1 for i in range(2,a): if l[i]<x: x = l[i] c+=1 elif l[i]>z: z = l[i] c+=1 else: pass print(c)
7
PYTHON3
t=int(input()) l=list(map(int,input().split())) q=l[0] w=l[0] v=0 for i in range(1,t): if l[i]>q: v=v+1 q=l[i] elif l[i]<w: v=v+1 w=l[i] print(v)
7
PYTHON3
n = int(input()) line = list(map(int, input().split())) MAX = MIN = line[0] count = 0 for i in line[1:]: if i > MAX: MAX = i count += 1 elif i < MIN: MIN = i count += 1 print(count)
7
PYTHON3
n = int(input()) l = list(map(int,input().split(" "))) b = l[0] w = l[0] nb = 0 for i in range(len(l)): if(l[i]>b): b = l[i] nb +=1 if(l[i]<w): w = l[i] nb += 1 print(nb)
7
PYTHON3
n = int(input()) a = list(map(int,input().split())) x = a[:1] for i in a: n -= 1 if min(x)<=i<=max(x) else 0 x+=[i] print(n)
7
PYTHON3
input() l=list(map(int,input().split())) a=max(l[0:2]) b=min(l[0:2]) x=int(a!=b) for i in range(2,len(l)): if l[i]>a : x+=1 a=l[i] if l[i]<b: x+=1 b=l[i] print(x)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; struct E { int v; E* next; E(int w, E* p = NULL) { v = w, next = p; } }; const int N = 1004; const int M = 1000; const int P = 1000000007; const int K = 256; const double PI = 3.14159265358979323846; const double eps = 1e-7; int n, m, k, l, d, n2, aa; int a[N], b[N]; int p[N], kp; int kol[K], len; bool mark[N]; bool ok; char s[N]; priority_queue<int> q, qq; void Primes(); int BinSearch(int* b, int n, int x); void Print(int par = 0); int main() { int i, j, nk; n = 0, m = 0, k = 0; scanf("%d\n", &n); scanf("%d", &aa); q.push(aa); qq.push(-aa); for (i = 1; i < n; i++) { scanf("%d", &aa); if (aa > q.top()) k++; if (-aa > qq.top()) k++; q.push(aa); qq.push(-aa); } printf("%d", k); return 0; } void Print(int par) { if (par == 0) { printf("n=%d m=%d\n", n, m); } else { for (int i = 0; !q.empty(); i++) { aa = q.top(); q.pop(); printf(" %d (%d)", aa, i); } printf("\n"); for (int i = 0; !qq.empty(); i++) { aa = qq.top(); qq.pop(); printf(" %d (%d)", -aa, i); } } printf("\n"); } void Primes() { int i, j, k, ki, pj; bool ok; p[0] = 2, p[1] = 3, p[2] = 5, p[3] = 7, p[4] = 11, p[5] = 13; p[6] = 17, p[7] = 19, p[8] = 23, p[9] = 29, p[10] = 31; p[11] = 37, p[12] = 41, p[13] = 43, p[14] = 47, p[15] = 53; p[16] = 59, p[17] = 61, p[18] = 67, p[19] = 71, p[20] = 73; p[21] = 79, p[22] = 83, p[23] = 89, p[24] = 97, p[25] = 101; for (i = 26; i < N; i++) { for (k = p[i - 1] + 2;; k += 2) { ki = (int)sqrt((double)k) + 2; for (ok = true, j = 0; pj = p[j], pj < ki; j++) if (k % pj == 0) { ok = false; break; } if (ok) break; } p[i] = k; } kp = i; } int BinSearch(int* b, int n, int x) { int l = 0, r = n - 1, m; if (x < b[0]) return -1; if (x > b[n - 1]) return n; while (l < r - 1) { m = (l + r) / 2; if (x == b[m]) return m; if (x < b[m]) r = m; else l = m; } if (x == b[l]) return l; if (x == b[r]) return r; return -2; }
7
CPP
n = int(input()) l = [] m = map(int,input().split()) for i in m : l.append(i) p = l[1:] g= [l[0]] s = 0 for i in p : if i > max(g) or i < min(g) : s += 1 g.append(i) print(s)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int ans = 0; int my_min, my_max, t; cin >> my_min; my_max = my_min; for (int i = 1; i < n; i++) { cin >> t; if (t > my_max) { my_max = t; ans++; } if (t < my_min) { my_min = t; ans++; } } cout << ans; return 0; }
7
CPP
''' Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. ''' #print ('Hello World') n=int(input()) l=list(map(int,input().split())) c=0 x=[] for i in range(n): if(i==0): x.append(l[i]) a=l[i] b=l[i] else: if(l[i]<a or l[i]>b): c+=1 x.append(l[i]) a=min(x) b=max(x) print(c)
7
PYTHON3
n = int(input()) l = list(map(int,input().split())) LESS = l[0] HIGH = l[0] del l[0] point = 0 for i in l: if i>HIGH: HIGH = i point += 1 if i<LESS: LESS = i point += 1 print(point)
7
PYTHON3
n=int(input()) scores=[int(x) for x in input().split()] s={scores[0]} amazing=0 for x in scores: if x<min(s) or x>max(s): amazing+=1 s=s|{x} print(amazing)
7
PYTHON3
n = int(input()) M = [int(d) for d in input().split()] L = [] m = 0 for i in range(n): if len(L) > 0 and( M[i] > max(L) or M[i] < min(L) ): m += 1 L.append(M[i]) print(m)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, amazing = 0, maxx, minn, k; cin >> n; cin >> k; maxx = k; minn = k; for (int i = 1; i < n; i++) { cin >> k; if (k > maxx) { maxx = k; amazing++; } else if (k < minn) { minn = k; amazing++; } } cout << amazing << endl; return 0; }
7
CPP
p=int(input()) c=0 a=list(map(int,input().split())) for i in range(p): l=u=0 if(i!=0): for j in range(0,i): if(a[i]>a[j]): u+=1 elif(a[i]<a[j]): l+=1 if((l==i)or(u==i)): c=c+1 print(c)
7
PYTHON3
n=int(input()) list1=[int(i) for i in input().split()] max1=list1[0];min1=list1[0] time=0 for i in list1: if i>max1: time+=1 max1=i elif i<min1: time+=1 min1=i print(time)
7
PYTHON3
t = int(input()) a = map(int, input().split()) a = list(a) ln = len(a) b = [] cont = 0 b.append(a[0]) for i in range(ln): min1 = min(b) max1 = max(b) if i >= 1: if a[i] <= min1 or a[i] >= max1: if a[i] not in b: b.append(a[i]) cont += 1 print(cont)
7
PYTHON3
n=input() a=input().split() for (i,o) in enumerate(a): a[i]=int(o) count=0 ma=a[0] mi=a[0] for i in a: if i>a[0]: if ma<i: count+=1 ma=i elif i<a[0]: if mi>i: count+=1 mi=i print(count)
7
PYTHON3
n=int(input()) p=list(map(int,input().split())) a=-1 b=10001 count=0 for i in range(n): if i>0 and (p[i]>a or p[i]<b): count+=1 a=max(a,p[i]) b=min(b,p[i]) print(count)
7
PYTHON3
n=int(input()) k=0 score=list(map(int,input().split())) for i in range(1,n): if max(score[:i])<score[i] or min(score[:i])>score[i]: k=k+1 print(k)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, x, l, r, p = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> x; if (i == 0) { l = x; r = x; } if (x < l) { p++; l = x; } if (x > r) { p++; r = x; } } cout << p << endl; return 0; }
7
CPP
n = int(input()) a = list(map(int, input().split())) x = a[0] y = a[0] count=0 for i in range(1,n): if a[i] > x: x = a[i] count += 1 elif a[i] < y: y = a[i] count +=1 print(count)
7
PYTHON3
n=int(input()) arr=list(map(int,input().split())) # w=float("inf") # b=-float("inf") w=arr[0] b=arr[0] c=0 for i in range(1,n): # print(i,w,b) if arr[i]>b: # print(1,i) b=arr[i] c+=1 elif arr[i]<w: # print(2,i) w=arr[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 for k in range(i): if scores[i] < scores[k]: count2+= 1 if count2 == k+1: cnt_amazing_performances += 1 print(cnt_amazing_performances)
7
PYTHON3
class CodeforcesTask155ASolution: def __init__(self): self.result = '' self.n = 0 self.performance = [] def read_input(self): self.n = int(input()) self.performance = [int(x) for x in input().split(" ")] def process_task(self): mx = mn = self.performance[0] amaze = 0 for a in self.performance[1:]: if a > mx: mx = a amaze += 1 elif a < mn: mn = a amaze += 1 self.result = str(amaze) def get_result(self): return self.result if __name__ == "__main__": Solution = CodeforcesTask155ASolution() Solution.read_input() Solution.process_task() print(Solution.get_result())
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) c=0 a=l[0] b=l[0] for i in range(1,n): if(l[i]<a): a=l[i] c+=1 elif(l[i]>b): b=l[i] c+=1 print(c)
7
PYTHON3
x=int(input()) l=list(map(int, input().split())) r=0 for i in range(1,x): if (l[i] > max(l[0:i])): r=r+1 if (l[i] < min(l[0:i])): r=r+1 print(r)
7
PYTHON3
def wonderful(lst): minimum, maximum, numb = lst[0], lst[0], 0 for i in range(1, len(lst)): if lst[i] > maximum: maximum = lst[i] numb += 1 if lst[i] < minimum: minimum = lst[i] numb += 1 return numb n = int(input()) a = [int(j) for j in input().split()] print(wonderful(a))
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] a=0 for i in range(1,n): if l[i]>max(l[0:i]) or l[i]<min(l[0:i]): a=a+1 print(a)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; long long A[n]; for (auto &i : A) cin >> i; long long mn = A[0], mx = A[0], c = 0; for (long long i = 1; i < n; i++) { if (A[i] > mx) { c++; mx = A[i]; } else if (A[i] < mn) { c++; mn = A[i]; } } cout << c << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; solve(); return 0; }
7
CPP
x = int(input()) amz =0 points = list(map(int, input().split())) p1 = points[0] p2 = points[0] for w in range(1, x): if points[w] > p1: p1 = points[w] amz += 1 elif points[w] < p2: p2 = points[w] amz += 1 print(amz)
7
PYTHON3
n=int(input()) a = [int(i) for i in input().split()] check1=a[0] check2=a[0] count=0 for i in range(1,n): if a[i]>check1: count+=1 check1=a[i] if a[i]<check2: count+=1 check2=a[i] print(count)
7
PYTHON3
contests = int(input()) ratings = list(map(int,input().split())) minRating = ratings[0] maxRating = ratings[0] amazing = 0 for i in range(1,contests): if ratings[i] < minRating: amazing += 1 minRating = ratings[i] if ratings[i] > maxRating: amazing += 1 maxRating = ratings[i] print(amazing)
7
PYTHON3
n = int(input()) list1 = list(map(int,input().split())) num = 0 if len(list1) > 1: for i in range(1,n): if list1[i] > max(list1[:i]) or list1[i] < min(list1[:i]): num += 1 print(num) else: print('0')
7
PYTHON3
from sys import stdin, stdout, stderr, setrecursionlimit import inspect, re setrecursionlimit(100000) def debug (*e): if not __debug__: print(*e, file=stderr) def dd(*vals): frame = inspect.getframeinfo(inspect.stack()[1][0]) vs = re.search("dd\((.+)\)", frame.code_context[0]).group(1).split(",") if vs: debug(",".join("{0} = {1}".format(vs[i], v) for i,v in enumerate(vals))) def trace(f): def traced(*args, **kw): debug("calling {} with args {}, {}".format(f.__name__, args, kw)) return f(*args, **kw) return traced #@trace #def f(x): def read(): return stdin.readline().rstrip() def readarr(sep=None, maxsplit=-1): return read().split(sep, maxsplit) def readint(): return int(read()) def readintarr(sep=None, maxsplit=-1): return [int(a) for a in readarr(sep, maxsplit)] #write(1, 2, 3, sep="-", end="!") def write(*args, **kwargs): sep = kwargs.get('sep', ' ') end = kwargs.get('end', '\n') stdout.write(sep.join(str(a) for a in args) + end) #writearr([1, 2, 3], sep="-", end="!") def writearr(arr, sep=' ', end='\n'): stdout.write(sep.join(str(a) for a in arr) + end) read() nums = readintarr() n = nums[0] mn = mx = n amazing = 0 for x in nums[1:]: if x > mx: #debug(x) mx = x amazing += 1 elif x < mn: #debug(x) mn = x amazing += 1 write(amazing)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) b=[] b.append(a[0]) h=0 for i in range(1,n): if(a[i]>max(b) or a[i]<min(b)): h=h+1 b.append(a[i]) print(h)
7
PYTHON3
n=int(input()) a=list(map(int,input().split(" "))) e=0 if n==1: print(0) else: if a[1]!=a[0]: e+=1 for x in range(2,n): if a[x]>max(a[:x]) or a[x]<min(a[:x]): e+=1 print(e)
7
PYTHON3
n=int(input()) list=[int(i) for i in input().split()] a=0 for i in range(len(list)-1): list1=list[0:i+1] if list[i+1]>max(list1) or list[i+1]<min(list1): a+=1 print(a)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int counter = 0; int minn = INT_MAX; int maxx = -INT_MAX; for (int i = 0; i < n; i++) { int x; cin >> x; if (i != 0) { if (x < minn || x > maxx) counter++; } minn = min(minn, x); maxx = max(maxx, x); } cout << counter; return 0; }
7
CPP
n = input() num = [int(i) for i in input().split()] ama = 0 ma = num[0] mi = num[0] for i in num : if i > ma : ma = i ama = ama + 1 if i < mi : mi = i ama = ama + 1 print(ama)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { long long int t, n, m, i, j, k, l, x, y, z; scanf("%lld", &t); long long int a, mx, mn, cnt = 0; scanf("%lld", &a); mx = mn = a; for (i = 1; i < t; ++i) { scanf("%lld", &a); if (a > mx) { mx = a; cnt++; } if (a < mn) { mn = a; cnt++; } } printf("%lld\n", cnt); return 0; }
7
CPP
input() ma = -1 mi = 10001 k = 0 for x in map(int,input().split()): if x > ma: ma = x k += 1 if x < mi: mi = x k += 1 print(k-2)
7
PYTHON3
#include <bits/stdc++.h> int a[1001]; int main() { int n, m = -1, M = 1e7, c = 0, x; scanf("%d", &n); while (n--) scanf("%d", &x), x > m ? m = x, c++ : 0, x < M ? M = x, c++ : 0; printf("%d", c - 2); }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; } int minn, maxx, count = 0; if (n > 2) { minn = min(a[0], a[1]); maxx = max(a[0], a[1]); for (int i = 2; i < n; ++i) { if (a[i] > maxx) { maxx = a[i]; count++; } else if (a[i] < minn) { minn = a[i]; count++; } } if (a[1] != a[0]) { count++; } cout << count; } else { if (n == 2) { if (a[0] != a[1]) cout << "1"; else cout << "0"; } else { cout << "0"; } } return 0; }
7
CPP
n=int(input()) list1=list(map(int,input().split())) min1=list1[0] max1=list1[0] c=0 for i in list1: if i>max1: c=c+1 max1=i elif i<min1: c=c+1 min1=i print(c)
7
PYTHON3
n = int(input()) k = list(map(int, input().split())) c = 0 best = k[0] worst = k[0] for i in range(1, n): if k[i] > best: c += 1 best = k[i] if k[i] < worst: c += 1 worst = k[i] print(c)
7
PYTHON3
t = int(input()) s = [int(x) for x in input().split()] m = [] c = 0 i = 0 while len(m) != len(s): m.append(s[i]) try: if s[i+1] > max(m) or s[i+1] < min(m): c += 1 except IndexError: break i += 1 print(c)
7
PYTHON3
n=int(input()) data=[int(i) for i in input().split()] nm=0 for i in range(1,n): t=data[0:i] if data[i]>max(t) or data[i]<min(t): nm+=1 print(nm)
7
PYTHON3
n = int(input()) tab = list(map(int , input().split())) themost = -1 theleast = 10001 am = -1 for i in tab: if i > themost or i < theleast: am += 1 if i > themost: themost = i if i < theleast: theleast = i print(am)
7
PYTHON3
input() game=list(map(int,input().split())) mi=ma=game[0] meow=0 for i in range(len(game)): if game[i]>ma: meow+=1 ma=game[i] elif game[i]<mi: meow+=1 mi=game[i] print(meow)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) count = 0 max1 = min1 = a[0] for i in range(n): if a[i] > max1: max1 = a[i] count+=1 if a[i] < min1: min1 = a[i] count+=1 print(count)
7
PYTHON3
import sys input = sys.stdin.readline ############ ---- Input Functions ---- ############ # — For taking integer inputs. def inp(): return(int(input())) # — For taking List inputs. def inlt(): return(list(map(int,input().split()))) # For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable. def insr(): s = input() return(list(s[:len(s) - 1])) # — For taking space seperated integer variable inputs. def invr(): return(map(int,input().split())) # -------------------------------------------------- num = inp() list_input = list(invr()) list_scores = [] list_scores.append(list_input[0]) count = 0 for i in range(1,num): if list_input[i] > max(list_scores) or list_input[i] < min(list_scores): count += 1 list_scores.append(list_input[i]) print(count)
7
PYTHON3