solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
n = int(input()) score = input().split() scoremax = int(score[0]) scoremin = int(score[0]) amazing = 0 for i in range(n): if int(score[i]) > scoremax: scoremax = int(score[i]) amazing+=1 if int(score[i]) < scoremin: scoremin = int(score[i]) amazing+=1 print(amazing)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) c=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=c+1 elif l[i]<l[j]: while(j>=0 and l[i]<l[j]): j=j-1 if j==-1: c=c+1 print(c)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split()] min = max = a[0] count = 0 for i in range(1,n): if a[i] < min: min = a[i] count+=1 elif a[i] > max: max = a[i] count+=1 print(count)
7
PYTHON3
n = int(input()) x = map(int, input().split()) s = [] a = 0 for i in x: s.append(i) if i == max(s) or i == min(s): a += 1 if s.count(i) > 1: if i == max(s) or i == min(s): a -= 1 print(a - 1)
7
PYTHON3
n=int(input()) data=[int(i) for i in input().split()] big=data[0] small=data[0] count=0 for i in range(1,n): if data[i]>big: big=data[i] count+=1 elif data[i]<small: small=data[i] count+=1 print(count)
7
PYTHON3
n=int(input()) p=input() p=p.split() c=0 a=int(p[0]) b=int(p[0]) for i in range(1,n): if int(p[i])>a: c+=1 a=int(p[i]) if int(p[i])<b: c+=1 b=int(p[i]) print(c)
7
PYTHON3
n = int(input()) scores = list(map(int,input().split(' '))) amazings = 0 for i in range(1, n): max_score = max(scores[:i]) min_score = min(scores[:i]) if scores[i] > max_score or scores[i] < min_score: amazings += 1 print(amazings)
7
PYTHON3
''' Created on ٠٦‏/١٢‏/٢٠١٤ @author: mohamed265 ''' n = int(input()) lis = [ int(x) for x in input().split()] ma = mi = lis[0] slon = 0 for i in range(1, n): if lis[i] > ma: ma = lis[i] slon += 1 elif lis[i] < mi: mi = lis[i] slon += 1 print(slon)
7
PYTHON3
n = int(input()) p = [int(_) for _ in input().split()] count = 0 for i in range(1, n): if max(p[:i]) < p[i] or min(p[:i]) > p[i]: count+=1 print(count)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) b=[] b.append(a[0]) x=0 for i in a: if i>max(b) or i<min(b): x=x+1 b.append(i) print(x)
7
PYTHON3
n = int(input()) a = [int(s) for s in input().split()] max = 0 min = 0 counter = 0 for i in range(n): if i == 0: max, min = a[i], a[i] continue else: if a[i] > max: counter += 1 max = a[i] elif a[i] < min: min = a[i] counter += 1 print(counter)
7
PYTHON3
n = int(input()) a = input().split() k = len(a) max = int(a[0]) min = int(a[0]) c = 0 for i in range(1,k): a[i] = int(a[i]) if a[i] > max: max = a[i] c += 1 elif a[i] < min: min = a[i] c += 1 print(c)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) x = y = a[0] cnt = 0 for i in range(1, n): if a[i] < x: x = a[i] cnt += 1 if a[i] > y: y = a[i] cnt += 1 print(cnt)
7
PYTHON3
n = int(input()) v = [int(x) for x in input().split()] amazing = 0 least = v[0] greatest = v[0] for x in v[1:]: if x > greatest: greatest = x amazing += 1 if x < least: least = x amazing += 1 print(amazing)
7
PYTHON3
n = int(input()) l = list(map(int, input().split(' '))) temp = [l[0]] l.pop(0) ans = 0 for i in l: if i>max(temp) or i<min(temp): ans+=1 temp.append(i) print(ans)
7
PYTHON3
n = int(input()) a = input().split(' ') m = int(a[0]) k = 0 s = int(a[0]) for i in range(n): a[i] = int(a[i]) if a[i] > m: k += 1 m = a[i] elif a[i] < s: k += 1 s = a[i] print(k)
7
PYTHON3
n = int(input().strip()) L = list(map(int,input().strip().split())) co = 0 maxP,lowP = -1,100000 if n!= 1: for i in range(n): if L[i] > maxP: maxP = L[i] co += 1 if L[i] < lowP: lowP = L[i] co += 1 print(str(co-2)) else: print(str(0))
7
PYTHON3
n=int(input()) s=input().split() maxx=int(s[0]) minn=int(s[0]) amazing=0 for i in range(1,n): x=int(s[i]) if(x>maxx): amazing+=1 maxx=x elif(x<minn): amazing+=1 minn=x print(amazing)
7
PYTHON3
n=int(input()) line=input().split() for i in range(n): line[i]=int(line[i]) a,b=line[0],line[0] ans=0 for i in range(1,n): if line[i]>a: a=line[i] ans+=1 if line[i]<b: b=line[i] ans+=1 print(ans)
7
PYTHON3
n=int(input()) s=[int(x) for x in input().split()] p=[s[0]] a=0 for i in range(1,n): if s[i]>max(p) or s[i]<min(p): a+=1 p.append(s[i]) print(a)
7
PYTHON3
a=int(input()) b=list(map(int,input().split())) biggest=b[0] lowest=b[0] counter=0 for i in range(a-1): if biggest<b[i+1]: biggest=b[i+1] counter+=1 if lowest>b[i+1]: lowest=b[i+1] counter+=1 print(counter)
7
PYTHON3
def func(n): k = list(map(int,input().split())) first_max = k[0] first_less = k[0] counter = 0 for i in range(1,len(k)): if k[i] < first_less: counter += 1 first_less = k[i] elif k[i] > first_max: counter += 1 first_max = k[i] print(counter) n = int(input()) func(n)
7
PYTHON3
n=int(input()) lst1=list(map(int,input().split()))[:n] c=0 Max=lst1[0] Min=lst1[0] for i in range(n): if(lst1[i]>Max): Max=lst1[i] c+=1 if(lst1[i]<Min): Min=lst1[i] c+=1 print(c)
7
PYTHON3
n=int(input()) s=map(int,input().split()) mn=mx=next(s) ans=0 for i in s: if i<mn:ans+=1;mn=i elif i>mx:ans+=1;mx=i print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, max, min, i, x, am = 0; cin >> n >> max; min = max; if (n == 1) cout << 0; else { for (i = 1; i <= n; i++) { cin >> x; if (x > max) { max = x; am++; } if (x < min) { min = x; am++; } } cout << am; } }
7
CPP
#I_love_%username% #Problem Link : http://codeforces.com/problemset/problem/155/A n , l = int(input()) , list(map(int , input().split())) low , high , amazing = l[0] , l[0] , 0 for i in l: if i > high: amazing += 1 high = i elif i < low: amazing += 1 low = i print(amazing)
7
PYTHON3
n = int(input()) a = [int(i) for i in input().split()] def res(a): lar = a[0] sma = a[0] c = 0 for i in range(len(a)-1): if( lar > a[i+1]): lar = a[i+1] c += 1 if(sma < a[i+1]): sma = a[i+1] c += 1 return c print(res(a))
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) smallest=largest=a[0] ans=0 for i in a[1:]: if(i<smallest): smallest=i ans+=1 if(i>largest): largest=i ans+=1 print(ans)
7
PYTHON3
n = int(input()) num = [int(i) for i in input().split()] MIN = num[0] MAX = num[0] count = 0 for i in range(1,n): if num[i]>MAX: MAX = num[i] count += 1 elif num[i]<MIN: MIN = num[i] count += 1 else: count = count print(count)
7
PYTHON3
exp=int(input()) recodsN=[int(r) for r in input().split()] maX,miN,cnt=recodsN[0],recodsN[0],0 for i in recodsN: if maX<i: maX,cnt=i,cnt+1 if miN>i: miN,cnt=i,cnt+1 print(cnt)
7
PYTHON3
n = int(input()) a = [int(x) for x in input().split()] maxx=a[0] i = int(0) j= int(0) minn=a[0] for x in range(0,n): if a[x]>maxx: maxx=a[x] i+=1 for x in range(0,n): if a[x]<minn: minn=a[x] j+=1 if n!=1: print(i+j) if n==1: print(0)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int n, a[1005], k = 0, max1, min1, l; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; max1 = a[0]; min1 = a[0]; for (int i = 0; i < n; i++) { if (a[i] > max1) { k++; max1 = a[i]; } if (a[i] < min1) { k++; min1 = a[i]; } } cout << k; return 0; }
7
CPP
n = int(input()) s = [int(i) for i in input().split()] perf = 0 for i in range(1,len(s)): if s[i] > max(s[:i]) or s[i] < min(s[:i]): perf+=1 print(perf)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) mi,ma=l[0],l[0] c=0 for i in range(1,n): if l[i]<mi: mi=l[i] c+=1 if l[i]>ma: ma=l[i] c+=1 print(c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, ma = 0, mi = 0, ud = 0; cin >> a; int b[a]; for (int i = 0; i < a; i++) { cin >> b[i]; } ma = b[0]; mi = b[0]; for (int i = 1; i < a; i++) { if (b[i] > ma) { ma = b[i]; ud++; } else if (b[i] < mi) { mi = b[i]; ud++; } } cout << ud; return 0; }
7
CPP
#include <bits/stdc++.h> int main() { int n, i, cnt = 0; scanf("%d", &n); int a[n]; for (i = 0; i < n; i++) { scanf("%d", &a[i]); } int maxx = a[0]; int minn = a[0]; for (i = 0; i < n; i++) { if (a[i] > maxx) { maxx = a[i]; cnt++; } if (a[i] < minn) { minn = a[i]; cnt++; } } printf("%d\n", cnt); return 0; }
7
CPP
n=int(input()) a=list(map(int,input().split())) mi=a[0] ma=a[0] b=mi c=ma tot=0 for i in range(n): mi=min(a[i],mi) ma=max(a[i],ma) if(mi!=b): tot=tot+1 if(ma!=c): tot=tot+1 b=mi c=ma print(tot)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) m=l[0] mn=l[0] cnt=0 for i in l: if i>m: m=i cnt+=1 if i<mn: cnt+=1 mn=i print(cnt)
7
PYTHON3
def main(): n=int(input()) arr= [int(i) for i in input().split()] mi=ma=arr[0] count=0 for i in range(1,n): if arr[i]>ma or arr[i]<mi: count+=1 mi= min(mi,arr[i]) ma=max(ma,arr[i]) print(count) return 0 if __name__ == '__main__': main()
7
PYTHON3
import sys n=int(input()) list=list(map(int,sys.stdin.readline().split())) count=0 a=list[:] max=a[0];min=a[0]; for i in range(1,n) : if a[i] > max or a[i] <min : count=count+1 if a[i] > max : max=a[i] else : min=a[i] print(count)
7
PYTHON3
n = int(input()) l = list(map(int,input().split())) # print(l) mi = l[0] ma = l[0] a = 0 for i in range(1,n): if l[i]>ma: ma = l[i] a+=1 if l[i]<mi: mi = l[i] a+=1 print(a)
7
PYTHON3
l = int(input()) a = list(map(int, input().split())) d = [] for i in range(1, l): if (a[i] == max(a[:i+1]) or a[i] == min(a[:i+1])) and (a[i] not in d) and (a[i] != a[0]): d.append(a[i]) print(len(d))
7
PYTHON3
n = int(input()) score = list(map(int,input().split())) count = 0 for i in range(n): if i==0: continue max_score = max(score[:i]) min_score = min(score[:i]) if score[i]>max_score: # print("max",score[i],max_score) count+=1 if score[i]<min_score: # print("min",score[i],min_score) count+=1 print(count)
7
PYTHON3
n=int(input()) l=[int(i) for i in input().split()] a=0 ma=l[0] mi=l[0] for i in range(1,n): if l[i]>ma: a+=1 ma=l[i] if l[i]<mi: a+=1 mi=l[i] print(a)
7
PYTHON3
n=int(input()) num=list(map(int,input().split())) if len(num)==1: print(0) elif len(num)==2 and num[0]==num[1]: print(0) else: f=0 c=0 for i in range(1,len(num)): if min(num[:i+1])==max(num[:i+1]): continue elif f==0: f=1 mi=min(num[:i+1]) ma=max(num[:i+1]) c+=1 back=num[:i+1] #print(back) if min(back)<mi: c+=1 mi=min(back) if max(back)>ma: c+=1 ma=max(back) print(c)
7
PYTHON3
n = int(input()) A = input() B = [] for i in A.split(): B.append(int(i)) max = B[0] min = B[0] Sum = 0 for j in range(1,n): if B[j]>max: Sum = Sum + 1 max = B[j] elif B[j]<min: Sum = Sum + 1 min = B[j] print(Sum)
7
PYTHON3
n = int(input()) p = list(map(int, input().split())) amazing = 0 for x in range(1, n): if p[x] == p[0]: continue elif p[x] > p[0]: for y in range(1, x): if p[x] <= p[y]: break else: amazing += 1 elif p[x] < p[0]: for y in range(1, x): if p[x] >= p[y]: break else: amazing += 1 print(amazing)
7
PYTHON3
n=int(input()) line=[int(j) for j in input().split()] count=0 MAX=line[0];MIN=line[0] if not n==1: for i in range(1,n): if line[i]<MIN: count+=1 MIN=line[i] if line[i]>MAX: MAX=line[i] count+=1 print(count)
7
PYTHON3
n = int(input()) points = list(input().split()) points = [int(i) for i in points] min = points[0] max = points[0] c = 0 for i in range(len(points)): if points[i] > max: max = points[i] c+=1 elif points[i] < min : min = points[i] c+=1 print(c)
7
PYTHON3
n = int(input()) e = input().split(" ") e = list(map(int, e)) c = 0 x = 0 for i in range(1, n): if e[i] < min(e[:i]) or e[i] > max(e[:i]): c += 1 x += 1 print(c)
7
PYTHON3
def solve(n, scores): lowest = scores[0] highest = scores[0] count = 0 for i in range(1, n): if scores[i] < lowest: count += 1 lowest = scores[i] if scores[i] > highest: count += 1 highest = scores[i] return count n = int(input()) scores = list(map(int, input().split())) print(solve(n, scores))
7
PYTHON3
n=int(input()) numofamazing=0 contest_points=list(map(int,input().split())) for i in range(1,len(contest_points)): high=True low=True past_scores=contest_points[:i] for score in past_scores: if(score>=contest_points[i]): high=False break for score in past_scores: if(score<=contest_points[i]): low=False break if(high or low): numofamazing=numofamazing+1 print(numofamazing)
7
PYTHON3
n = int(input()) x = list(map(int, input().split())) mx = mn = x[0] cnt = 0 for i in x[1:]: if i < mn: mn = i cnt += 1 elif i > mx: mx = i cnt += 1 print(cnt)
7
PYTHON3
#!/usr/bin/env python3 def main(): n = int(input()) l = [ int(i) for i in input().split() ] ans = 0 ma = l[0] mi = l[0] for i in range(1,n): if l[i] > ma: ans+=1 ma = l[i] if l[i] < mi: ans+=1 mi = l[i] print(ans) main()
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) i=1 max=a[0] min=a[0] count=0 while(i<n): if a[i]<min: count+=1 min = a[i] elif a[i]>max: count+=1 max=a[i] i+=1 print(count)
7
PYTHON3
n=int(input()) k=input("").split() count=0 best = worst = int(k[0]) for i in range(1,n): if int(k[i]) > best: best=int(k[i]) count+=1 elif int(k[i]) < worst: worst=int(k[i]) count+=1 print(count)
7
PYTHON3
# MANISH GUPTHA # VNR VIGNAYANA JOTYHI INSTITUE OF TECHNOLOGY HYDERABAD n=int(input()) l=list(map(int,input().split())) count=0 min=l[0] max=l[0] for i in range(1,n): if(l[i]>min and max<l[i]): max=l[i] count=count+1 if l[i]<min: count=count+1 min=l[i] print(count)
7
PYTHON3
n=int(input()) l=input().split() if(n==1): print(0) else: a=0 for i in range(n): l[i]=int(l[i]) if(l[0]>l[1]): nowmax=l[0] nowmin=l[1] a+=1 else: nowmax=l[1] nowmin=l[0] a+=1 if(l[1]==l[0]): a=0 i=2 while(i<n): if(l[i]>nowmax): nowmax=l[i] a+=1 elif(l[i]<nowmin): nowmin=l[i] a+=1 i+=1 print(a)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) if n==1: print(0) else: res=1 if l[0]==l[1]: res=0 for i in range(2,n): if l[i]>max(l[0:i]): res+=1 if l[i]<min(l[0:i]): res+=1 print(res)
7
PYTHON3
n=int(input()) score=input().split() minn=int(score[0]) maxx=int(score[0]) total=0 for i in range(len(score)): if(int(score[i])>maxx): total+=1 maxx=int(score[i]) elif(int(score[i])<minn): total+=1 minn=int(score[i]) print(total)
7
PYTHON3
n=int(input()) c_r=list(map(int,input().split())) bp=c_r[0] wp=c_r[0] c=0 for x in range(1,len(c_r)): if c_r[x]>bp: bp=c_r[x] c+=1 elif c_r[x]<wp: wp=c_r[x] c+=1 print(c)
7
PYTHON3
n=int(input()) marks=[int(x) for x in input().split()] i=0 j=0 best=marks[0] worst=marks[0] for z in range (1,n): if marks[z]>best: best=marks[z] i+=1 if marks[z]<worst: worst=marks[z] j+=1 print(i+j)
7
PYTHON3
n = int(input()) score = [int(x) for x in input().split()] high = score[0] low = score[0] ans = 0 for i in range(1, n): if score[i] > high: high = score[i] ans += 1 elif score[i] < low: low = score[i] ans += 1 print(ans)
7
PYTHON3
n=int(input()) w=0 ar=list(map(int, input().split())) max=min=ar[0] for i in range (1,n): if ar[i]>max: w+=1 max=ar[i] if ar[i]<min: w+=1 min=ar[i] print (w)
7
PYTHON3
n=int(input()) a=[int(i) for i in input().split()] t=0 for i in range(1,n): b=0 k=0 bb='no' kk='no' z=a[i] for j in range(i): if z>a[j]: b=b+1 elif z<a[j]: k=k+1 if k==i: kk='yes' elif b==i: bb='yes' if bb=='yes' or kk=='yes': t=t+1 print(t)
7
PYTHON3
input() a = list(map(int, input().split())) minn = a.pop(0) maxx = minn k = 0 for i in a: if i > maxx: maxx = i k += 1 if i < minn: minn = i k += 1 print(k)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) a,b,c=0,0,0 for i in range(1,n): for j in range(0,i): if l[i]>l[j]: a=1 else: a=0 break if a==1: c=c+1 for j in range(0,i): if l[i]<l[j]: b=1 else: b=0 break if b==1: c=c+1 print(c)
7
PYTHON3
# bsdk idhar kya dekhne ko aaya hai, khud kr!!! # from math import * # from itertools import * t = int(input()) arr = list(map(int, input().split())) min_ = arr[0] count_ = 0 max_ = arr[0] for i in range(0, t): if arr[i] > max_: count_ += 1 max_ = arr[i] elif arr[i] < min_: min_ = arr[i] count_ += 1 elif min_ <= arr[i] <= max_: continue print(count_)
7
PYTHON3
n = int(input()) a = list(map(int, input().split())) m1 = a[0]; m2 = a[0]; ans = 0 for i in range(1, n): if a[i] > m1: m1 = a[i] ans += 1 elif a[i] < m2: m2 = a[i] ans += 1 print(ans)
7
PYTHON3
n = int(input()) s = input().split() for i in range(n): s[i] = int(s[i]) u = 0 mi = s[0] ma = s[0] for i in range(1,n): if s[i] < mi: u = u+1 mi = s[i] if s[i] > ma: u = u+1 ma = s[i] print(u)
7
PYTHON3
n=int(input()) a=list(map(int,input().split())) b=[a[0]] count=0 for i in a: if i > max(b) or i < min (b): count=count+1 b.append(i) print(count)
7
PYTHON3
n=int(input()) h=input().split() a=0 max=int(h[0]) min=int(h[0]) for i in range(1,n): mi=int(h[i]) if mi>max: max=mi a+=1 if mi<min: min=mi a+=1 print(a)
7
PYTHON3
from sys import stdin, stdout import math,sys from itertools import permutations, combinations from collections import defaultdict,deque,OrderedDict import bisect as bi import heapq ''' #------------------PYPY FAst I/o--------------------------------# def I():return (int(stdin.readline())) def In():return(map(int,stdin.readline().split())) ''' #------------------Sublime--------------------------------------# #sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w'); def I():return (int(input())) def In():return(map(int,input().split())) def main(): try: n=I() l=list(In()) best,worst=l[0],l[0] ans=0 for i in range(1,n): if l[i]>best: ans+=1 best=l[i] if l[i]<worst: ans+=1 worst=l[i] print(ans) except: pass M = 998244353 P = 1000000007 if __name__ == '__main__': for _ in range(1): main()
7
PYTHON3
n=int(input()) a=list(map(int,input().split()))[:n] b=[] count=0 for i in a: if len(b)==0: b.append(i) continue b.sort() if i <b[0]: count+=1 if i>b[len(b)-1]: count+=1 b.append(i) print(count)
7
PYTHON3
_ = input() scores = list(map(int, input().split())) amazing, highest, lowest = 0, scores[0], scores[0] for score in scores[1:]: if score < lowest: lowest = score amazing += 1 elif score > highest: highest = score amazing += 1 print(amazing)
7
PYTHON3
n=int(input()) l=list(map(int,input().split())) max=l[0];min=l[0];cnt=0 for i in range(1,len(l)): if(l[i]>max): cnt=cnt+1 max=l[i] elif(l[i]<min): cnt=cnt+1 min=l[i] print(cnt)
7
PYTHON3
n=int(input()) k=list(map(int,input().split())) mi=ma=k[0] c=0 for i in range(1,n): if k[i]>ma: ma=k[i] c+=1 elif k[i]<mi: mi=k[i] c+=1 print(c)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; int count = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; } int max = arr[0], min = arr[0]; for (int i = 0; i < n; i++) { if (arr[i] > max) { max = arr[i]; count++; } if (arr[i] < min) { min = arr[i]; count++; } } cout << count; return 0; }
7
CPP
#include <bits/stdc++.h> int main() { int competencia[1000]; int n, i, mayor, menor, cont = 0; do { scanf("%d", &n); } while (n < 1 || n > 1000); for (i = 0; i < n; i++) { do { scanf("%d", &competencia[i]); } while (competencia[i] < 0 || competencia[i] > 10000); } mayor = competencia[0]; menor = competencia[0]; for (i = 1; i < n; i++) { if (competencia[i] > mayor) { cont++; mayor = competencia[i]; } if (competencia[i] < menor) { cont++; menor = competencia[i]; } } printf("%d", cont); return 0; }
7
CPP
n=int(input()) m=input().split() z=0 for i in range(n): m[i]=int(m[i]) if n==1: z=0 else: p=min(m[0],m[1]) q=max(m[0],m[1]) for i in range(2,n): if m[i]<p: p=m[i] z=z+1 if p<=m[i]<=q: p=p z=z if m[i]>q: q=m[i] z=z+1 if m[0]!=m[1]: z=z+1 else: z=z print(z)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; bool isprime(long long int n) { if (n == 0 || n == 1) return false; else { for (long long int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } } return true; } long long int nextprime(long long int n) { long long int x = -1; for (long long int i = n + 1;; i++) { if (isprime(i)) { x = i; break; } } return x; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; long long int arr[n]; for (long long int i = 0; i < n; i++) cin >> arr[i]; long long int mi = arr[0], mx = arr[0], count = 0; for (long long int i = 1; i < n; i++) { if (arr[i] < mi) { mi = arr[i]; count++; } if (arr[i] > mx) { mx = arr[i]; count++; } } cout << count << endl; }
7
CPP
#include <bits/stdc++.h> int main() { long long n; scanf("%I64d", &n); long long a[n]; long long i, j; for (i = 0; i < n; i++) { scanf("%I64d", &a[i]); } long long count = 0; long long less = 0; long long more = 0; for (i = 1; i < n; i++) { for (j = 0; j < i; j++) { if (a[j] < a[i]) { count++; } } if (count == j) { more++; } count = 0; } count = 0; for (i = 1; i < n; i++) { for (j = 0; j < i; j++) { if (a[i] < a[j]) { count++; } } if (count == j) { less++; } count = 0; } printf("%I64d", (more + less)); }
7
CPP
__author__ = 'Bian' n = int(input()) con = [int(x) for x in input().split()] ma , mi = con[0], con[0] cnt = 0 for i in con[1:]: if i > ma: ma = i cnt += 1 elif i < mi: mi = i cnt += 1 print(cnt)
7
PYTHON3
input() mx = None mn = None res = 0 for a in map(int,input().split()): if mx is None: mn = a mx = a else: if a > mx: mx = a res = res +1 if a < mn: mn = a res = res+1 print(res)
7
PYTHON3
n = int(input()) l = [int(x) for x in input().split()] p = l[0] q = l[0] s = 0 for i in range(1,n): if l[i]>p: p = l[i] s += 1 elif l[i]<q: q = l[i] s += 1 print(s)
7
PYTHON3
n = int(input()) if n == 1: print(0) else: count = 0 contests = input().split() for k in range(n): contests[k] = int(contests[k]) for i in range(1, n): if contests[i] > max(contests[:i]): count = count + 1 if contests[i] < min(contests[:i]): count = count + 1 print(int(count))
7
PYTHON3
n=int(input()) score=[int(i)for i in input().split()] count=0 for i in range(0,n): if i==0: maxx=score[i] minn=score[i] else: if score[i]>maxx: maxx=score[i] count+=1 if score[i]<minn: minn=score[i] count+=1 print(count)
7
PYTHON3
n=int(input()) a=[int(i) for i in input().split()] ans=0 maxi=a[0] mini=a[0] for y in range(1,n): if(a[y]>maxi): maxi=a[y] ans+=1 elif(a[y]<mini): mini=a[y] ans+=1 print(ans)
7
PYTHON3
n=int(input()) scores=list(map(int,input().split())) count=0 best=scores[0] worse=scores[0] for i in range(1,n): if scores[i]>best: count+=1 best=scores[i] if scores[i]<worse: count+=1 worse=scores[i] print(count)
7
PYTHON3
#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 max = a[0]; int min = a[0]; int count = 0; for (int i = 1; i < n; i++) { if (a[i] > max) { max = a[i]; count++; } else if (a[i] < min) { min = a[i]; count++; } } cout << count; return 0; }
7
CPP
n = int(input()) c = list(map(int, input().split())) a = 0 for i in range(1, n): if c[i] > max(c[:i]) or c[i] < min(c[:i]): a += 1 print(a)
7
PYTHON3
n = int(input()) m = map(int, input().split()) m = list(m) f = 0 for i in range(1, len(m)): if min(m[:i:]) <= m[i] and m[i] <= max(m[:i:]): continue else: f += 1 print(f)
7
PYTHON3
n = int(input()) a = 0 l = list(map(int, input().split())) m = l[0] x = l[0] for i in l: if(x < i): a+=1 x = i elif(m > i): a+=1 m = i print(a)
7
PYTHON3
n=int(input()) l1=[int(h) for h in input().split()] da=l1[0] xiao=l1[0] f=0 for x in range(1,n): if l1[x]>da: da=l1[x] f+=1 if l1[x]<xiao: xiao=l1[x] f+=1 print(int(f))
7
PYTHON3
import math n=int(input()) a=list(map(int,input().split())) maxi = a[0] mini = a[0] amazings = 0 for i in range(1,n): if a[i]>maxi: amazings+=1 maxi=a[i] elif a[i]<mini: amazings+=1 mini=a[i] print(amazings)
7
PYTHON3
n = int(input()) ls = [int(i) for i in input().split()] maxi = ls[0] mini = ls[0] count = 0 for i in ls: if i>maxi: maxi = i count+=1 elif i<mini: mini = i count+=1 print(count)
7
PYTHON3
n = (int) (input()) l = input() l = [int((list(l.split(" ")))[i]) for i in range(n)] tl=l[0] tu=l[0] t=0 for i in range(1,n): if(l[i]<tl): tl=l[i] t+=1 if(l[i]>tu): tu=l[i] t+=1 print(t)
7
PYTHON3
n = int(input()) lst = [int(x) for x in input().split()] ct = 0 mi = lst[0] mx = lst[0] for x in lst[1:]: if x > mx or x < mi: ct += 1 if x > mx: mx = x if x < mi: mi = x print (ct)
7
PYTHON3
inputCount = int(input()) inputs = list(map(int, input().split())) currentNumber = 0 lowestNumber = 10000 highestNumber = 0 amazingScore = 0 if inputCount > 1: for _ in range(len(inputs)): currentNumber = inputs[_] if currentNumber < lowestNumber: lowestNumber = currentNumber if _ > 0: amazingScore = amazingScore + 1 if currentNumber > highestNumber: highestNumber = currentNumber if _ > 0: amazingScore = amazingScore + 1 print(amazingScore) else: print(0)
7
PYTHON3
t = int(input()) lst = [] ans = 0 s = str(input()) lt = s.split() dum = int(lt.pop(0)) lst += [dum] for i in lt: i = int(i) if i < min(lst) or i > max(lst): ans += 1 lst += [i] print(ans)
7
PYTHON3