solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
number_of_contest = int(input())
points = list(map(int, input().split()))
count = 0
def check(points, point):
# print(points, point, max(points), min(points))
if point < min(points) or point > max(points):
return True
return False
for i in range(1, number_of_contest):
if check(points[:i], points[i]):
count += 1
print(count)
| 7 | PYTHON3 |
def main():
n = int(input())
score = list(map(int,input().split()))
max_score = min_score = score[0]
score.remove(max_score)
output = 0
for i in score:
if i > max_score:
max_score = i
output += 1
elif i < min_score:
min_score = i
output += 1
print(output)
main() | 7 | PYTHON3 |
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
t = 1
for _ in range(t):
n = ii()
p = li()
count = 0
for i in range(1, len(p)):
if p[i] > max(p[:i]) or p[i] < min(p[:i]):
count += 1
print(count)
| 7 | PYTHON3 |
import sys
it = iter(sys.stdin.read().splitlines())
n = int(next(it))
p = [int(x) for x in next(it).split()]
count = 0
for x in range(1,len(p),1):
indexMax = 0
indexMin = 0
for y in range(x):
if p[y] < p[x]:
indexMin+=1
if p[y] > p[x]:
indexMax += 1
if indexMin == x or indexMax == x:
count+=1
print(count) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
string bin(int n);
void generate100binary();
bool valid(int x, int y) { return (x >= 0 and y >= 0); }
int n, w;
vector<pair<long long, long long>> v;
long long dp[1000][1000];
int maximumweight(long long i, long long weight, long long value) {
static long long dp[1000][1000];
if (weight > w) return -1;
if (i >= v.size()) {
if (weight <= w)
return dp[i][weight];
else
return -1;
}
if (dp[i][weight])
return dp[i][weight];
else
return dp[i][weight] = max(
maximumweight(i + 1, weight + v[i].first, value + v[i].second),
maximumweight(i + 1, weight, value));
return max(maximumweight(i + 1, weight + v[i].first, value + v[i].second),
maximumweight(i + 1, weight, value));
}
bool validd(int x, int n) { return (x >= 0 and x < n); }
void code() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
;
int cnt = 0;
for (int i = 1; i < n; i++) {
vector<int> copp;
for (int j = 0; j < i; j++) {
copp.push_back(v[j]);
}
if (v[i] > *max_element(copp.begin(), copp.end()) or
v[i] < *min_element(copp.begin(), copp.end()))
cnt++;
}
cout << cnt << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t = 1;
while (t--) {
code();
}
}
string bin(int n) {
string s = "";
bitset<7> bs = n;
for (int i = 0; i < bs.size(); i++) {
s += to_string(bs[i]);
}
reverse(s.begin(), s.end());
return s;
}
void generate100binary() {
for (int i = 0; i <= 100; i++) {
cout << i << " : ";
cout << bin(i) << '\n';
}
}
| 7 | CPP |
n = int(input())
l = list(map(int,input().split()))
l1 = [l[0]]
count = 0
for i in range(1,n):
if l[i]<min(l1) or l[i]>max(l1):
count += 1
l1.append(l[i])
print(count) | 7 | PYTHON3 |
import math
import itertools
gh = lambda: map( int, input().split() )
mod = 998244353
mod = int(mod)
def main():
input()
a = list( gh() )
mx, cnt = a[0], 0
mn = mx
for i in a:
if i > mx:
cnt += 1
mx = i
if i < mn:
mn = i
cnt += 1
print( cnt )
main() | 7 | PYTHON3 |
n = int(input().strip())
scores = tuple(map(int, input().strip().split()))
max_s, min_s = scores[0], scores[0]
ans = 0
for s in scores:
if s < min_s:
ans += 1
min_s = s
elif s > max_s:
ans += 1
max_s = s
print(ans) | 7 | PYTHON3 |
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
n = int(data())
arr = l()
low, high, answer = arr[0], arr[0], 0
for i in arr[1:]:
if low > i:
answer += 1
low = i
if high < i:
answer += 1
high = i
out(answer)
| 7 | PYTHON3 |
n = int(input())
scores = list(map(int, input().split()))
sol = 0
for i in range(1, n):
if all(scores[i] < el for el in scores[0:i]) or all(scores[i] > el for el in scores[0:i]):
sol += 1
print(sol) | 7 | PYTHON3 |
n=int(input())
ar=list(map(int,input().split()))
mi,ma=ar[0],ar[0]
s=0
for x in range(1,n):
if ar[x]<mi:
mi=ar[x]
s+=1
if ar[x]>ma:
ma=ar[x]
s+=1
print(s)
| 7 | PYTHON3 |
n = int(input())
a = list(map(int, input().split()))
min = max = a[0]
amazing = 0
for i in a:
if i < min:
min = i
amazing += 1
elif i > max:
max = i
amazing += 1
print(amazing) | 7 | PYTHON3 |
input()
arr = list(map(int, input().split()))
a, b = arr[0], arr[0]
am = 0
for x in arr:
if x > a:
a = x
am += 1
elif x < b:
b = x
am += 1
print(am)
| 7 | PYTHON3 |
n = int(input())
l1 = list(map(int, input().split()))
count = 0
for i in range(1, n):
a = max(l1[0:i])
b = min(l1[0:i])
if l1[i] > a or l1[i] < b:
count += 1
else:
pass
print(count) | 7 | PYTHON3 |
import sys
def main():
n = int(input())
test=input()
marks = (test.split())
max=int(marks[0])
min=int(marks[0])
i=0
count=0
while i<n:
if int(marks[i])>int(max):
max=marks[i]
count=count+1
if int(marks[i])<int(min):
min=marks[i]
count=count+1
i=i+1
print (count)
if __name__=='__main__':
main()
| 7 | PYTHON3 |
n = int(input())
li = [int(i) for i in input().split()]
u = 0
a = 1
while(a < len(li)):
if((max(li[0:a]) < li[a]) or (min(li[0:a]) > li[a])):
u = u + 1
a = a + 1
print(u) | 7 | PYTHON3 |
x=int(input())
y=list(map(int,input().split()))
c=0
w=y[0]
h=y[0]
for i in y:
if i>h:
c+=1
h=i
elif i<w:
w=i
c+=1
print(c) | 7 | PYTHON3 |
z,zz=input,lambda:list(map(int,z().split()))
zzz=lambda:[int(i) for i in stdin.readline().split()]
szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
p=ceil(x**.5)+1
for i in range(2,p):
if (x%i==0 and x!=2) or x==0:return 0
return 1
def dfs(u,visit,graph):
visit[u]=True
for i in graph[u]:
if not visit[i]:
dfs(i,visit,graph)
###########################---Test-Case---#################################
"""
"""
###########################---START-CODING---##############################
n=int(z())
l=zzz()
x=l[0]
ans=0
mx,mi=x,x
for i in l[1:]:
if i>mx:
ans+=1
mx=max(i,mx)
if i<mi:
ans+=1
mi=min(i,mi)
print(ans)
| 7 | PYTHON3 |
n = int(input())
points = [int(k) for k in input().split(' ')]
MaxPoints, MinPoints, WeirdPoints = -1, 10001, -2
for i in points:
if i > MaxPoints:
MaxPoints = i
WeirdPoints += 1
if i < MinPoints:
MinPoints = i
WeirdPoints += 1
print(WeirdPoints)
| 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(1,len(a)):
if a[i]>max(a[0:i]) or a[i]<min(a[0:i]):
c=c+1
print(c) | 7 | PYTHON3 |
from sys import stdin
def get_user_input():
return list(map(int, stdin.readline().rstrip().split()))
n = int(input())
input_list = get_user_input()
res = 0
last_min = input_list[0]
last_max = input_list[0]
for i in range(1, len(input_list)):
if input_list[i] < last_min:
res += 1
if input_list[i] > last_max:
res += 1
last_min = min(last_min, input_list[i])
last_max = max(last_max, input_list[i])
print(res)
| 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
if len(a)!=1:
if a[0]==a[1]:
ans=0
else:
ans=1
max1=max(a[0],a[1])
min1=min(a[0],a[1])
for i in range(2,n):
if a[i]<min1:
min1=a[i]
ans=ans+1
if a[i]>max1:
max1=a[i]
ans=ans+1
print(ans)
else:
print(str(0)) | 7 | PYTHON3 |
n=int(input())
a=[int(p) for p in input().split()]
total=0
x=a[0]
y=a[0]
for i in range(1,n):
if a[i]>x:
x=a[i]
total=total+1
elif a[i]<y:
y=a[i]
total=total+1
else:
total=total
print(total)
| 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
ma=mi=a[0]
s=0
for i in range(1,n):
if a[i]>ma:
s+=1
ma=a[i]
elif a[i]<mi:
s+=1
mi=a[i]
print(s)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long a[n];
cin >> a[0];
long long min = a[0];
long long max = a[0];
long long cnt = 0;
for (int i = 1; i < n; i++) {
cin >> a[i];
if (a[i] > max) {
max = a[i];
cnt++;
}
if (a[i] < min) {
min = a[i];
cnt++;
}
}
cout << cnt;
}
| 7 | CPP |
n = int(input())
arr = [int(a) for a in input().split()]
max = arr[0]
min = arr[0]
count = 0
for i in range(1, n):
if arr[i] > max:
max = arr[i]
count += 1
if arr[i] < min:
min = arr[i]
count += 1
print(count) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
int N;
cin >> N;
int arr[N];
for (int i = 0; i < N; i++) cin >> arr[i];
int ans = 0, max = arr[0], min = arr[0];
for (int x : arr) {
if (x > max) {
max = x;
ans++;
} else if (x < min) {
min = x;
ans++;
}
}
cout << ans;
}
| 7 | CPP |
n = int(input())
S = [int(i) for i in input().split()]
minx = maxx = S[0]
k = 0
for i in range(1, n):
if(S[i]<minx):
minx = S[i]
k += 1
if(S[i] >maxx):
maxx = S[i]
k += 1
print(k) | 7 | PYTHON3 |
n = int(input())
points = list(map(int, input().split(' ')))
i=0
amazing = 0
passed = [points[0]]
while i<len(points):
if points[i] > max(passed):
amazing+=1
if points[i] < min(passed):
amazing+=1
passed.append(points[i])
i+=1
print(amazing)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
long long n, a, res;
int main() {
cin >> n;
if (n != 0) cin >> a;
long long mx = a;
long long mn = a;
for (long long i = 0; i < n - 1; i++) {
cin >> a;
if (a > mx) {
res++;
mx = a;
} else if (a < mn) {
res++;
mn = a;
}
}
cout << res;
}
| 7 | CPP |
N = int(input())
P = list(map(int, input().split()))
B = P[0]
W = P[0]
A = 0
for index in range(1, N):
S = P[index]
if S > B:
A += 1
B = S
if S < W:
A += 1
W = S
print(A) | 7 | PYTHON3 |
a=int(input())
b=list(map(int,input().split()))
d=0
if len(b)<=1:
d=0
elif b[1]>b[0]:
c1=b[1]
c2=b[0]
d+=1
elif b[1]==b[0]:
c1=b[1]
c2=b[0]
else:
c1=b[0]
c2=b[1]
d+=1
for i in range(2,len(b)):
if b[i]>c1:
d+=1
c1=b[i]
elif b[i]<c2:
d+=1
c2=b[i]
print(d) | 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
i=1
v=0
s=[l[0]]
while i<len(l):
if l[i]>max(s) or l[i]<min(s):
v+=1
s.append(l[i])
i+=1
print(v)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int b, i, c, a1, j, b1, c1, n, m, a[1001];
string s, s1;
cin >> n;
cin >> a[1];
for (i = 2; i <= n; i++) {
cin >> a[i];
b = a[i];
sort(a + 1, a + i + 1);
if (a[1] == b && a[1] != a[2]) m++;
if (a[i] == b && a[i] != a[i - 1]) m++;
}
cout << m << endl;
}
| 7 | CPP |
input()
r = -1
for x in map(int, input().split()):
if r < 0:
r = 0
mx = mn = x
if x > mx:
r += 1
mx = x
if x < mn:
r += 1
mn = x
print(r) | 7 | PYTHON3 |
a=int(input())
l=input().split()
l1=[]
for i in l:
i=int(i)
l1.append(i)
lenth=len(l1)
n=1
summ=0
while n<lenth:
l2=l1[:n]
max1=max(l2)
min1=min(l2)
num1=l1[n]
if num1>max1 or num1<min1:
summ+=1
n+=1
print(summ)
| 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))
t=0
mi = a[0]
ma = a[0]
for i in range(n):
if a[i]<mi:
mi = a[i]
t+=1
if a[i]>ma:
ma = a[i]
t+=1
print(t)
| 7 | PYTHON3 |
n = int(input())
li = [int(_) for _ in input().split()]
a = b = li[0]
ans = 0
for i in range(1, n):
ans += 1 if li[i] < a or li[i] > b else 0
a = min(a, li[i])
b = max(b, li[i])
print(ans)
| 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
more=l[0]
less=l[0]
p=0
try:
for i in range(1,n):
if l[i]>more or l[i]<less:
p+=1
more=max(more,l[i])
less=min(less,l[i])
except:
p=0
print(p)
| 7 | PYTHON3 |
n=input()
x=input().split()
s=[]
for i in x:
k=int(i)
s.append(k)
a=s[0]
b=s[0]
z=0
u=0
for i in s:
if i>a:
a=i
z+=1
if i<b:
b=i
u+=1
f=z+u
print(f)
| 7 | PYTHON3 |
n = int(input())
x = input()
l = [int(i) for i in x.split()]
temp = 0
maxn = l[0]
minn = l[0]
for i in range(1, len(l)):
if l[i] < minn:
minn = l[i]
temp += 1
if l[i] > maxn:
maxn = l[i]
temp += 1
print(temp)
| 7 | PYTHON3 |
n = int(input())
arrayContests = input().split()
for i in range(n):
arrayContests[i] = int(arrayContests[i])
amazing = 0
minPoints = arrayContests[0]
maxPoints = arrayContests[0]
for i in range(1, n):
if arrayContests[i] > maxPoints:
amazing += 1
maxPoints = arrayContests[i]
elif arrayContests[i] < minPoints:
amazing += 1
minPoints = arrayContests[i]
print("%d" % (amazing)) | 7 | PYTHON3 |
import sys
n = sys.stdin.readline().split()[0]
scores = [int(i) for i in sys.stdin.readline().split()]
i = 1
amazing = 0
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 i == less_count or i == more_count:
amazing += 1
i += 1
print(amazing) | 7 | PYTHON3 |
n=int(input())
list1=[int(i) for i in input().split()]
x=0
for i in range(1,n,1):
list2=list1[:i]
if list1[i]>max(list2) or list1[i]<min(list2):
x=x+1
print(x) | 7 | PYTHON3 |
n = int(input())
scores = list(map(int, input().split(" ")))
high = low = scores[0]
out = 0
for i in range(1, len(scores)):
if scores[i] > high:
out += 1
high = scores[i]
elif scores[i] < low:
out += 1
low = scores[i]
print(out)
| 7 | PYTHON3 |
a=int(input())
b=[int(i) for i in input().split( )]
k=0
i=1
f=1
while i<a:
if b[i]>max(b[:f]) or b[i]<min(b[:f]):
k+=1
i+=1
f+=1
print(k) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, ans = 0, cd = 0, a[1002];
cin >> n;
for (i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1)
ans = 0;
else {
for (i = 1; i < n; i++) {
cd = 0;
for (j = 0; j < i; j++) {
if (a[i] > a[j]) cd++;
}
if (cd == i) ans++;
}
for (i = 1; i < n; i++) {
cd = 0;
for (j = 0; j < i; j++) {
if (a[i] < a[j]) cd++;
}
if (cd == i) ans++;
}
}
cout << ans << endl;
return 0;
}
| 7 | CPP |
input()
arr = [int(x) for x in input().split()]
k = 0
mn = arr[0]
mx = arr[0]
for x in arr[1:]:
if x < mn:
mn = x
k += 1
elif x > mx:
mx = x
k += 1
print(k)
| 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
b=[a[0]]
s=0
for i in range(1,n):
if a[i]>max(b) or a[i]<min(b):
s+=1
b.append(a[i])
print (s)
| 7 | PYTHON3 |
x,lis = int(input()),list(map(int, input().split(" ")))
mini,maxi,supp = lis[0],lis[0],0
for i in range(1, len(lis)):
if lis[i] < mini: mini,supp = lis[i], supp+1
elif lis[i] > maxi: maxi,supp = lis[i], supp+1
print(supp)
| 7 | PYTHON3 |
a=int(input())
b=input()
c=b.split(' ')
d=[]
d.append(int(c[0]))
x=0
for i in range(a-1):
if int(c[i+1])<min(d):
x=x+1
elif int(c[i+1])>max(d):
x=x+1
d.append(int(c[i+1]))
print(x) | 7 | PYTHON3 |
n = int(input())
s = [int(x) for x in input().split()]
mins = maxs = s[0]
val = 0
for si in s[1:]:
if si < mins:
mins = si
val += 1
elif si > maxs:
maxs = si
val += 1
print(val) | 7 | PYTHON3 |
n = int(input())
arr = list(map(int, input().split()))[:n]
operationArr = []
amazing = 0
maxP = arr[0]
minP = arr[0]
# for i in range(n):
# operationArr.append(arr[i])
# if(i >0):
# if(operationArr[i] == max(operationArr) and operationArr[i] > maxP):
# amazing = amazing + 1
# maxP = operationArr[i]
# elif(operationArr[i] == min(operationArr) and operationArr[i] < minP):
# amazing = amazing + 1
# minP = operationArr[i]
i = 1
for i in range(n):
if(arr[i]>maxP):
maxP = arr[i]
amazing = amazing + 1
elif(arr[i]<minP):
minP = arr[i]
amazing = amazing + 1
print(amazing)
| 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
d=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:
d=d+1
elif l[i]<l[j]:
while(j>=0 and l[i]<l[j]):
j=j-1
if j==-1:
d=d+1
print(d) | 7 | PYTHON3 |
n = int(input())
scores = [int (i) for i in input().split()]
if n == 1:
print (0)
else:
max_score = scores[0]
min_score = max_score
count = 0
for i in range(1,n):
if scores[i] > max_score:
max_score = scores[i]
count += 1
elif scores[i] < min_score:
min_score = scores[i]
count += 1
print (count)
| 7 | PYTHON3 |
"""For testing snippets."""
input()
points = list(map(int, input().split()))
high = low = points[0]
count = 0
for i in points:
if i > high:
count += 1
high = i
elif i < low:
count += 1
low = i
print(count)
| 7 | PYTHON3 |
def solve(scores):
smallest = largest = scores[0]
amazing = 0
for score in scores[1:]:
if(score < smallest):
smallest = score
amazing+=1
if(score > largest):
largest = score
amazing+=1
return amazing
if __name__ == "__main__":
n = int(input())
scores = list(map(int,input().split()))
print(solve(scores)) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, sum = 0, n, mx, mn;
scanf("%d", &n);
scanf("%d", &mx);
mn = mx;
for (int i = 1; i < n; i++) {
scanf("%d", &a);
if (a > mx) {
mx = a;
sum++;
} else if (a < mn) {
mn = a;
sum++;
}
}
printf("%d\n", sum);
return 0;
}
| 7 | CPP |
number=int(input())
points=list(map(int,input().split()))
max=points[0]
min=points[0]
times=0
for i in points[1:]:
if i>max:
times+=1
max=i
elif i < min:
times+=1
min=i
print(times) | 7 | PYTHON3 |
events = int(input())
results = list(map(int, input().split()))
best = results[0]
worst = results[0]
surprize = 0
for i in range(events):
if results[i] > best:
best = results[i]
surprize += 1
elif results[i] < worst:
worst = results[i]
surprize += 1
print(surprize) | 7 | PYTHON3 |
a=int(input())
l=list(map(int,input().split()))
u=0
ind=1
le=len(l)
for i in range(le):
if i>0:
if l[i]>max(l[:ind]) or l[i]<min(l[:ind]):
u+=1
ind+=1
print(u)
| 7 | PYTHON3 |
n = int(input())
l = list(map(int, input().split()))
c = 0
for i in range(1,n):
if l[i] > max(l[:i]) or l[i] < min(l[:i]): c += 1
print(c)
| 7 | PYTHON3 |
# coding: utf-8
n = int(input())
li = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
if i == 0:
min = li[i]
max = li[i]
elif min > li[i]:
min = li[i]
cnt += 1
elif max < li[i]:
max = li[i]
cnt += 1
print(cnt)
| 7 | PYTHON3 |
n = int(input())
a = [int(i) for i in input().split()]
b = [a[0]]
c = 0
for i in range(1,n):
if a[i] < min(b) or a[i] > max(b):
c+=1
b.append(a[i])
print(c) | 7 | PYTHON3 |
t = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(1, t):
if min(a[:i]) > a[i] or max(a[:i]) < a[i]: c += 1
print(c) | 7 | PYTHON3 |
number_of_contests = int(input(""))
contest_scores = input("").split(" ")
contest_scores
first_time = True
smallest_number = int()
greatest_number = int()
no_of_times = 0
for contest_score in contest_scores:
contest_score = int(contest_score)
if first_time is True:
first_time = False
smallest_number = contest_score
greatest_number = contest_score
else:
if contest_score > greatest_number:
no_of_times = no_of_times + 1
greatest_number = contest_score
if contest_score < smallest_number:
no_of_times = no_of_times + 1
smallest_number = contest_score
print(no_of_times) | 7 | PYTHON3 |
n = int(input())
massif = [int(a) for a in input().split()]
maximum = massif[0]
minimum = massif[0]
answer = 0
for a in massif:
if a < minimum:
answer += 1
minimum = a
elif a > maximum:
answer += 1
maximum = a
print(answer) | 7 | PYTHON3 |
n = int(input())
v = list(map(int, input().split()))
res = 0
min = 10001
max = -1
for i in range(1, len(v)):
if v[i] > v[i - 1] and v[i] > max:
res += 1
max = v[i]
if v[i - 1] < min:
min = v[i - 1]
elif v[i] < v[i - 1] and v[i] < min:
res += 1
min = v[i]
if v[i - 1] > max:
max = v[i - 1]
print(res)
| 7 | PYTHON3 |
input()
points = [int(i) for i in input().split()]
count, max_past, min_past = 0, points[0], points[0]
for i in range(1, len(points)):
now = points[i]
if max_past < now or min_past > now:
count += 1
max_past = max(max_past, now)
min_past = min(min_past, now)
print(count) | 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
m1=l[0]
m2=l[0]
a=l[0]
c=0
for i in range(1,n):
b=l[i]
if(b<m1):
a=b
m1=b
c+=1
elif(b>m2):
a=b
m2=b
c+=1
print(c)
| 7 | PYTHON3 |
n = int(input())
a = [int(x) for x in input().split(' ')]
am = 0
mi = a[0]
ma = a[0]
for i in range(1,n):
if a[i] > ma:
ma = a[i]
am += 1
if a[i] < mi:
mi = a[i]
am += 1
print(am) | 7 | PYTHON3 |
ans = 0
input()
scores = [int(x) for x in input().split()]
ignore = 0
for i in scores:
if ignore == 0:
maxValue = i
minValue = i
ignore+=1
else:
if i > maxValue:
maxValue = i
ans += 1
elif i < minValue:
minValue = i
ans += 1
print(ans)
| 7 | PYTHON3 |
n = int(input())
l = list(map(int, input().split()))
worst = l[0]
best = l[0]
ans = 0
for i in range(1, n):
if l[i] > best:
best = l[i]
ans += 1
if l[i] < worst:
worst = l[i]
ans += 1
print(ans)
| 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
max=l[0]
min=l[0]
c=0
for i in range(1,n):
if(l[i]>max):
max=l[i]
c+=1
if(l[i]<min):
min=l[i]
c+=1
print(c) | 7 | PYTHON3 |
#Author: Adisbek
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(1,n):
k = max(a[0:i]);l=min(a[0:i])
if a[i] > k or a[i] < l:
s = s + 1
print(s)
| 7 | PYTHON3 |
def all_the_same(elements):
return len(set(elements)) in (0, 1)
n = int(input())
a = input().split(' ')
if n!=1:
if all_the_same(a):
print(0)
else:
l = int(a[0])
m = int(a[0])
cnt = 0
for i in a:
lastl = l
lastm = m
l = min(l,int(i))
m = max(m,int(i))
if lastl != l or lastm != m:
cnt += 1
print(cnt)
else:
print(0)
| 7 | PYTHON3 |
n = int(input())
points = list(map(int, input().split()))
min_points, max_points, surprise_counter = points[0], points[0], 0
for i in range(1, n):
if points[i] > max_points:
max_points, surprise_counter = points[i], surprise_counter + 1
elif points[i] < min_points:
min_points, surprise_counter = points[i], surprise_counter + 1
print(surprise_counter) | 7 | PYTHON3 |
k=input()
s=list(map(int,input().split()))
counter=int(0)
max=min=s[0]
for i in range (len(s)):
if s[i]>max:
max=s[i]
counter+=1
if s[i]<min:
min=s[i]
counter+=1
print(counter) | 7 | PYTHON3 |
import sys
import math
n=int(input())
lista=[int(x) for x in input().strip().split()]
mina,maxa,conta=lista[0],lista[0],0
for i in range(1,len(lista)):
if(lista[i]>maxa):
maxa=lista[i]
conta+=1
elif(lista[i]<mina):
mina=lista[i]
conta+=1
print(conta) | 7 | PYTHON3 |
n=int(input())
ar = list(map(int, input().split( )[:n]))
max=min=int(ar[0])
cnt=0
n=n-1
i=1
while(n):
tem=int(ar[i])
if(tem>max):
cnt=cnt+1
max=tem
if(tem<min):
cnt=cnt+1
min=tem
i=i+1
n=n-1
print(cnt)
| 7 | PYTHON3 |
# A. I_love_%username%
n = int(input())
scores = list(map(int,input().split()))
worst = scores[0]
best = scores[0]
amazing = 0
for i in range(1,n):
#print(scores[i],best,worst)
if scores[i]>best:
amazing += 1
best = scores[i]
elif scores[i]<worst:
amazing += 1
worst = scores[i]
print(amazing) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0, minn, maxx;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
minn = v[0];
maxx = v[0];
for (int i = 1; i < n; i++) {
if (v[i] > maxx)
cnt++, maxx = v[i];
else if (v[i] < minn)
cnt++, minn = v[i];
}
cout << cnt << endl;
}
| 7 | CPP |
n=int(input())
s=[int(i) for i in input().split()]
minnum=s[0]
maxnum=s[0]
special=0
for i in range(n):
if s[i]>maxnum:
maxnum=s[i]
special+=1
elif s[i]<minnum:
minnum=s[i]
special+=1
print(special)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n];
int count = 0;
int max, min;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
max = arr[0];
min = arr[0];
for (int i = 1; i < n; i++) {
if (max < arr[i]) {
max = arr[i];
count++;
}
if (arr[i] < min) {
min = arr[i];
count++;
}
}
cout << count << endl;
}
| 7 | CPP |
'''input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
'''
n = int(input())
l = [int(i) for i in input().split(' ')]
x = l[0]
y = l[0]
ans = 0
for i in range(1, n):
if l[i] > x:
ans += 1
if l[i] < y:
ans += 1
x = max(x, l[i])
y = min(y, l[i])
print(ans) | 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
a=0
for i in range(1,n):
a+=(l[i]<min(l[:i]) or l[i]>max(l[:i]))
print(a) | 7 | PYTHON3 |
n = int(input())
num = input()
arr = []
count = 0
for i in range(0,len(num)):
if num[i] == ' ':
arr.append(int(num[count:i]))
count = i+1
elif i == len(num)-1:
arr.append(int(num[count:len(num)]))
getting_data = []
''''
Vasya considers a coder's performance in a contest amazing in two situations:
he can break either his best or his worst performance record
'''
amazing = 0
for i in range(0,len(arr)):
if i>0:
getting_data.sort()
min = getting_data[0]
max = getting_data[len(getting_data)-1]
if arr[i] > max or arr[i] < min:
amazing +=1
getting_data.append(arr[i])
print(amazing) | 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))
m=a[0]
mi=a[0]
c=0
for i in a[1:]:
if (i<mi):
c+=1
mi=i
elif(i>m):
c+=1
m=i
print(c) | 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))[:n]
s,b,c=a[0],a[0],0
for i in range(1,n):
if s>a[i]:
s=a[i]
c+=1
if b<a[i]:
b=a[i]
c+=1
print(c) | 7 | PYTHON3 |
# I_love_%username%
t = int(input())
l = list(map(int,input().split()))
maxi,mini,cnt = l[0],l[0],0
for i in range(1,len(l)):
if l[i] < mini:
mini = l[i]
cnt += 1
elif l[i] > maxi:
maxi = l[i]
cnt += 1
print(cnt) | 7 | PYTHON3 |
n = int(input())
count = -1
a = list(map(int,input().split()))
l = []
for i in range(n):
y = a[i]
if y not in l:
l.append(y)
l.sort()
if y == l[0] or y == l[-1]:
count+= 1
else:
pass
print(count)
| 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
max1=a[0]
min1=a[0]
res=0
for i in a:
if i>max1:
max1=i
res+=1
elif i<min1:
min1=i
res+=1
print(res) | 7 | PYTHON3 |
def getInts():
return [int(s) for s in input().split()]
def getInt():
return int(input())
def getStrs():
return [s for s in input().split()]
def getStr():
return input()
def listStr():
return list(input())
import collections as c
def solve():
N = getInt()
P = getInts()
best, worst = -10**9, 10**9
ans = 0
for i in range(N):
if P[i] > best:
best = P[i]
if i > 0:
ans += 1
if P[i] < worst:
worst = P[i]
if i > 0:
ans += 1
print(ans)
return
solve()
| 7 | PYTHON3 |
a=int(input())
k=list(map(int,input().split()))
mina=k[0]
maxa=k[0]
cnt=0
for i in range(1,a):
if k[i]>maxa:
maxa=k[i]
cnt+=1
elif k[i]<mina:
mina=k[i]
cnt+=1
print(cnt) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, arr[100001];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int Min = 0, Max = 0;
for (int i = 1; i < n; i++) {
if (arr[i] > arr[0]) {
Max = arr[i];
break;
}
}
for (int i = 1; i < n; i++) {
if (arr[i] < arr[0]) {
Min = arr[i];
break;
}
}
int count = 0;
if (Max == 0) {
Max = arr[0];
} else
count++;
if (Min == 0) {
Min = arr[0];
} else
count++;
for (int i = 1; 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 |
input(); li = list(map(int, input().split()))
c = 0; li2 = []
for i in li:
if len(li2) >= 1:
if max(li2)<i: c += 1
elif min(li2)>i: c+=1
li2.append(i)
print(c) | 7 | PYTHON3 |
n = int(input())
l = [int(x) for x in input().split()]
small = 0
for i in range(1,n):
for j in range(0,i):
if l[j] >= l[i]:
break
if j == i-1:
small += 1
big = 0
for i in range(1,n):
for j in range(0,i):
if l[j] <= l[i]:
break
if j == i-1:
big += 1
print(small+big) | 7 | PYTHON3 |
t=int(input())
l=list(map(int,input().split()))
c=0
for i in range(1,t):
if (l[i]==max(l[:i+1]) and l[i] not in l[:i]) or (l[i]== min(l[:i+1]) and l[i] not in l[:i]):
c+=1
print(c) | 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
mi=l[0]
mx=l[0]
c=0
for i in range(1,len(l)):
if l[i]>mx:
mx=l[i]
c+=1
elif l[i]<mi:
mi=l[i]
c+=1
print(c)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int i, a, b, n, rt = 0, pt = 0, j;
int ch[9000];
int t = 0, p = 0, q = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &ch[i]);
}
for (i = n - 1; i >= 1; i--) {
t = 0;
p = 0;
q = 0;
for (j = i - 1; j >= 0; j--) {
if (ch[i] > ch[j]) {
t++;
}
if (ch[i] < ch[j]) {
p++;
}
if (ch[i] == ch[j]) {
q++;
}
}
if (t > 0 && p == 0 && q == 0) {
rt++;
}
if (p > 0 && t == 0 && q == 0) {
pt++;
}
}
printf("%d\n", rt + pt);
return 0;
}
| 7 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.