solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
n = int(input())
marks = list(map(int, input().split()))
amz = 0
for i in range(1, n):
s = marks[:i]
if all (m<marks[i] for m in s) or all (m>marks[i] for m in s):
amz += 1
print(amz)
| 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
b=a[0]
c=a[0]
A=0
for i in a[1:]:
if i>b:
A+=1
b=i
elif i<c:
A+=1
c=i
print(A)
| 7 | PYTHON3 |
n = int(input())
b = list(map(int, input().split()))
m, M = b[0], b[0]
a = 0
for i in range(1, n):
if b[i] > M:
M = b[i]
a += 1
if b[i] < m:
m = b[i]
a += 1
print(a)
| 7 | PYTHON3 |
n = int(input())
aux = input()
scores = []
scores = aux.split()
for i in range(n):
scores[i] = int(scores[i])
min = max = scores[0]
count=0
for i in range(1,n):
if scores[i] < min:
count+=1
min = scores[i]
elif scores[i]>max:
count+=1
max = scores[i]
print(count)
| 7 | PYTHON3 |
n = int(input())
score = list(map(int,input().split()))
heighest = score[0]
lowest = score[0]
c = 0
for i in range(1,n):
if score[i]>heighest:
heighest = score[i]
c += 1
elif score[i]<lowest:
lowest = score[i]
c+=1
else:
pass
print(c) | 7 | PYTHON3 |
n = int(input())
l = list(map(int, input().split()[:n]))
l_min = l[0]
l_max = l[0]
count = 0
for i in range(n):
if l[i] > l_max or l[i] < l_min:
l_max = max(l_max, l[i])
l_min = min(l_min, l[i])
count += 1
print(count) | 7 | PYTHON3 |
inp,a,ans=[],[],0
n=int(input())
inp=input()
for s in inp.split(' '):
a.append(int(s))
mn,mx=a[0],a[0]
for i in a:
if i<mn or i>mx:
ans=ans+1
mx=max(mx,i)
mn=min(mn,i)
print(ans) | 7 | PYTHON3 |
n = int(input())
p = list(map(int, input().split()))
a = 0
max,min = p[0], p[0]
for i in range (1,n):
if p[i] > max:
max = p[i]
a += 1
elif p[i] < min:
min = p[i]
a += 1
print(a) | 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int n, i, c = 0;
scanf("%d", &n);
int a[n];
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int max = a[0];
int min = a[0];
for (i = 0; i < n; i++) {
if (a[i] > max) {
max = a[i];
c++;
}
}
for (i = 0; i < n; i++) {
if (a[i] < min) {
min = a[i];
c++;
}
}
printf("%d", c);
}
| 7 | CPP |
q = input()
l = [int(k) for k in input().split()]
if len(l) == 1:
r = 0
else:
if l[0] != l[1]:
r =1
else:
r = 0
mini = min(l[0], l[1])
maxi = max(l[0], l[1])
for i in l[2:]:
if i < mini:
mini = i
r += 1
elif i > maxi:
maxi = i
r += 1
print(r)
| 7 | PYTHON3 |
n = int(input())
s = list(map(int,input().split()))
min1=s[0]
max1=s[0]
c=0
for i in range(1,len(s)):
if s[i] > max1:
c+=1
max1=s[i]
elif s[i] < min1:
c+=1
min1=s[i]
print(c)
| 7 | PYTHON3 |
n = int(input())
a = list(map(int, input().split()))
minv, maxv = a[0], a[0]
count = 0
for i in a:
if i > maxv:
maxv = i
count += 1
elif i < minv:
minv = i
count += 1
print(count) | 7 | PYTHON3 |
n=int(input())
xx=[int(i) for i in input().split()]
s=0
x=xx[0]
y=xx[0]
for i in range(1,n):
if xx[i]>x:
s+=1
x=xx[i]
if xx[i]<y:
s+=1
y=xx[i]
print(s)
| 7 | PYTHON3 |
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 31/08/2020
from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
n = ii1()
arr = iia()
l = h = arr[0]
res = 0
for i in range(1, n):
if arr[i] > h or arr[i] < l:
res += 1
h = max(h, arr[i])
l = min(l, arr[i])
print(res)
| 7 | PYTHON3 |
n = int(input())
order = list(map(int, input().split(" ")))
max = order[0]
min = order[0]
amazing = 0
for i in range(0, n):
current = order[i]
if (current > max):
max = current
amazing += 1
if (current < min):
min = current
amazing += 1
print(amazing) | 7 | PYTHON3 |
n = int(input())
line = [int(i) for i in input().split()]
max_score = line[0]
min_score = line[0]
amazing = 0
for i in range(1,n):
if line[i] < min_score:
amazing += 1
min_score = line[i]
if line[i] > max_score:
amazing += 1
max_score = line[i]
print(amazing)
| 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))
mini=a[0]
maxi=a[0]
cnt=0
for i in range(1,n):
if mini>a[i]:
cnt+=1
mini=a[i]
if maxi<a[i]:
cnt+=1
maxi=a[i]
print(cnt) | 7 | PYTHON3 |
leng = int(input())
A = list(map(int,input().split()))
n = A[0]
m = n
cnt = 0
for i in A:
if i>m:
cnt += 1
m = i
if i<n:
cnt += 1
n = i
print(cnt) | 7 | PYTHON3 |
import math
from collections import Counter
def get(f):
return map(f, input().split())
def main():
n = int(input())
contests = list(get(int))
mi, ma = contests[0], contests[0]
cnt = 0
for i in range(1, n):
cur = contests[i]
if cur < mi:
mi = cur
cnt += 1
continue
if cur > ma:
ma = cur
cnt += 1
continue
print(cnt)
main()
| 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))
mx,mn=a[0],a[0]
amaz=0
for i in range(1,n):
if(a[i]>mx):
mx=a[i]
amaz=amaz+1
elif(a[i]<mn):
mn=a[i]
amaz=amaz+1
print(amaz)
| 7 | PYTHON3 |
n = input()
a = map(int,input().split())
mn = 10005
mx = -10005
cnt = 0
for i in a:
if(i < mn):
mn = i
cnt+=1
if(i>mx):
mx = i
cnt+=1
print(cnt-2) | 7 | PYTHON3 |
n = int(input())
nums = map(int, input().split())
min_point = max_point = next(nums)
count_amazing = 0
for m in nums:
if m > max_point:
max_point = m
count_amazing += 1
elif m < min_point:
min_point = m
count_amazing += 1
print(count_amazing)
| 7 | PYTHON3 |
def answer():
n = int(input())
a = input().split()
a = [int(x) for x in a]
b =[a[0]]
i=1
ans=0
while i<len(a):
if a[i]>max(b):ans+=1
if a[i]<min(b):ans+=1
b.append(a[i])
i+=1
return ans
print(answer()) | 7 | PYTHON3 |
n=int(input())
ll=list(map(int,input().split()))
c=0
b,w=ll[0],ll[0]
for i in range(1,n):
if b<ll[i]:
b=ll[i]
c+=1
elif w>ll[i]:
w=ll[i]
c+=1
print(c) | 7 | PYTHON3 |
import math
n = int(input())
a = input().split(' ')
a[0] = int(a[0])
gmax = a[0]
gmin = a[0]
count = 0
for i in range(1,n):
a[i] = int(a[i])
if gmin > a[i]:
count = count + 1
gmin = a[i]
elif gmax < a[i]:
count = count + 1
gmax = a[i]
print(count) | 7 | PYTHON3 |
n = int (input())
a = [int(i) for i in input().split(" ")]
best = a[0]
worst = a[0]
ans = 0
for i in range (1,n):
if a [i] > best:
best = a [i]
ans += 1
if a [i] < worst:
worst = a [i]
ans += 1
print (ans)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, i, ans = 0, max, min;
cin >> n;
long long int a[n];
for (i = 0; i < n; i++) cin >> a[i];
min = a[0];
max = a[0];
for (i = 1; i < n; i++) {
if (a[i] < min) {
ans++;
min = a[i];
}
if (a[i] > max) {
ans++;
max = a[i];
}
}
cout << ans;
return 0;
}
| 7 | CPP |
n,a = int(input()),list(map(int,input().split()))
mi,ma,c = a[0],a[0],0
for i in range(1,n):
if a[i] < mi:
mi = a[i]
c+=1
if a[i] > ma:
ma = a[i]
c+=1
print(c) | 7 | PYTHON3 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
ls=[int(x) for x in input().split()]
max=ls[0]
min=ls[0]
s=0
for p in ls[1:]:
if p>max:
s+=1
max=p
elif p<min:
s+=1
min=p
print(s)
| 7 | PYTHON3 |
num = int(input())
answer = 0
results = list(map(int, input().split()))
min_res = results[0]
max_res = results[0]
for i in results[1 : ]:
if i > max_res:
max_res = i
answer += 1
elif i < min_res:
min_res = i
answer += 1
print(answer)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, a[10000], max = 0, count = 0, min = 10000, r = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 10000) {
r++;
}
if (a[i] > max) {
max = a[i];
count++;
}
if (a[i] < min) {
min = a[i];
count++;
}
}
count = count - 2;
if (r == n) {
cout << 0 << endl;
} else if (r == 1) {
cout << 1 << endl;
} else {
if (count > 0) {
cout << count << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
| 7 | CPP |
def solution() -> int:
n = int(input())
ra = list(map(int, input().split()))
bare, full = ra[0], ra[0]
cnt = 0
for i in ra:
if i > full:
full = i
cnt += 1
if i < bare:
bare = i
cnt += 1
return cnt
print(solution())
| 7 | PYTHON3 |
x = int(input())
y = list(map(int,input().split()))
amazing = 0
min = y[0]
max = y[0]
for i in range (x):
if y[i] > max:
max = y[i]
amazing += 1
if y[i] < min:
min = y[i]
amazing += 1
print(amazing)
| 7 | PYTHON3 |
dec=0
n=int(input())
s=input().split()
t=[]
for i in range(n):
if i==1 and s[i]!=s[0]:
dec+=1
elif i>1:
if int(s[i])>max(t) or int(s[i])<min(t):
dec+=1
t.append(int(s[i]))
print(dec) | 7 | PYTHON3 |
import sys
a = int(sys.stdin.readline())
n = sys.stdin.readline().split()
count=0
maxm=int(n[0])
minm=int(n[0])
for i in range (1,a):
v=int(n[i])
if v> maxm:
maxm=v
count+=1
elif v < minm:
minm=v
count+=1
print(count)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, nb = 0, i, maxi = 0, mini = 0, a = 0;
cin >> n >> a;
mini = a;
maxi = a;
for (i = 1; i < n; i++) {
cin >> a;
if (mini < a) {
mini = a;
nb++;
}
if (maxi > a) {
maxi = a;
nb++;
}
}
cout << nb;
}
| 7 | CPP |
n=int(input())
arr=list(map(int,input().strip().split(' ')))
ma,mi=arr[0],arr[0];ctr=0
for i in arr:
if i>ma:
ma=i;ctr+=1
if i<mi:
mi=i;ctr+=1
print(ctr) | 7 | PYTHON3 |
n = int(input())
c = [int(i) for i in input().split()]
c_min=c[0]
c_max=c[0]
amaz = 0
for i in range(n-1):
i = i+1
if c[i]<c_min:
c_min = c[i]
amaz +=1
elif c[i]>c_max:
c_max = c[i]
amaz +=1
print(amaz) | 7 | PYTHON3 |
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
def sin():
return input()
def ain():
return list(map(int, sin().split()))
def sain():
return input().split()
def iin():
return int(sin())
MAX = float('inf')
MIN = float('-inf')
def main():
n = iin()
l = ain()
if n == 1:
print(0)
sys.exit(0)
count = 0
maxi = l[0]
mini = l[0]
for i in range(1, n):
if l[i] > maxi:
maxi = l[i]
count += 1
if l[i] < mini:
mini = l[i]
count += 1
print(count)
# Fast IO Template starts
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# Fast IO Template ends
if __name__ == "__main__":
main() | 7 | PYTHON3 |
n = int(input())
st = [int(x) for x in input().split()]
max_val = min_val = st[0]
count = 0
if len(st)==1:
print(count)
else:
for i in range(1,len(st)):
if st[i] > max_val:
max_val = st[i]
count+=1
if st[i] < min_val:
min_val = st[i]
count+=1
print(count) | 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
amz=0
x=y=a[0]
for i in a[1:]:
if i>x:
x=i
amz+=1
if i<y:
y=i
amz+=1
print(amz)
| 7 | PYTHON3 |
n = int(input())
arr = list(map(int, input().split()))
#print(arr)
mmin = 0
mmax = 0
mmin = arr[0]
mmax = arr[0]
ans = 0
for i in range(1, n):
if arr[i] > mmax:
ans += 1
mmax = arr[i]
if arr[i] < mmin:
mmin = arr[i]
ans += 1
print(ans) | 7 | PYTHON3 |
import sys
n = int(input())
elems = list(map(int, input().split()))
low,high = elems[0], elems[0]
count = 0
for elem in elems:
if elem>high:
count += 1
high = elem
if elem<low:
count += 1
low = elem
print(count)
| 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split(" ")))
l=[a[0]]
c=0
for i in range(1,n):
if a[i] not in l:
l.append(a[i])
if a[i]==max(l) or a[i]==min(l):
c+=1
print(c) | 7 | PYTHON3 |
n=int(input())
mi, ma=10002, -1
c=-2
for i in map(int,input().split()):
if i>ma:
ma=i
c+=1
if i<mi:
mi=i
c+=1
print(c) | 7 | PYTHON3 |
#__author__ = 'Anonymeyll'
input()
a = [int(x) for x in input().split()]
mi = a[0]
ma = mi
t = 0
for i in a:
if i > ma:
ma = i
t += 1
elif i < mi:
mi = i
t += 1
print(t) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
long long powermod(long long x, long long n, long long M) {
long long result = 1;
while (n > 0) {
if (n % 2 == 1) result = (result * x) % M;
x = (x * x) % M;
n = n / 2;
}
return result;
}
vector<long long> readll() {
cin >> ws;
vector<long long> v;
string input;
getline(cin, input);
cout << input;
istringstream is(input);
long long num;
while (is >> num) v.push_back(num);
return v;
}
long long modinv(long long n, long long p) { return powermod(n, p - 2, p); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long fact[1000005], invf[1000005];
void facmod(long long n, long long M) {
long long i;
fact[0] = fact[1] = 1;
for (i = 2; i <= n; ++i) {
fact[i] = ((fact[i - 1]) % M * (i % M)) % M;
}
invf[n] = modinv(fact[n], M);
for (i = n - 1; i >= 0; --i) {
invf[i] = invf[i + 1] * (i + 1);
invf[i] %= M;
}
}
void solve() {
long long i, n;
cin >> n;
long long a[n + 4];
long long c = 0, mn = LLONG_MAX, mx = LLONG_MIN;
for (i = 0; i < n; ++i) {
cin >> a[i];
if (i == 0) {
mn = mx = a[i];
} else {
if (a[i] > mx || a[i] < mn) {
c++;
mn = min(mn, a[i]);
mx = max(mx, a[i]);
}
}
}
cout << c;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
;
long long t = 1;
while (t--) {
solve();
}
return 0;
}
| 7 | CPP |
n = int(input())
a = list(map(int, input().split()))
min_a = a[0]
max_a = a[0]
ans = 0
for ai in a:
if ai < min_a:
min_a = ai
ans += 1
elif ai > max_a:
max_a = ai
ans += 1
print(ans)
| 7 | PYTHON3 |
n = int(input())
a = list(map(int, input().split()))
maks = 0
min = 0
kol = 0
for i in range(n):
if i == 0:
maks = min = a[i]
if a[i]>maks:
kol = kol + 1
maks = a[i]
elif a[i]<min:
kol =kol + 1
min = a[i]
print(kol)
| 7 | PYTHON3 |
n = int(input())
kolvo = 0
spisok = list(input().split())
max1 = min1 = int(spisok[0])
for i in spisok:
a=int(i)
if a > max1:
max1 = a
kolvo += 1
elif a < min1:
min1 = a
kolvo += 1
print (kolvo)
| 7 | PYTHON3 |
n = input()
lst = [int(i) for i in input().split()]
MIN = lst[0]
MAX = lst[0]
k = 0
for i in lst:
if i > MAX:
MAX = i
k += 1
if i < MIN:
MIN = i
k += 1
print(k) | 7 | PYTHON3 |
n=int(input())
p=[int(i) for i in input().split()]
max_=p[0]
min_=p[0]
s=0
for i in range(1,n):
if p[i]>max_:
max_=p[i]
s+=1
elif p[i]<min_:
min_=p[i]
s+=1
print(s)
| 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
l,g,c=a[0],a[0],0
for i in a:
if i>g:
c+=1
g=i
elif i<l:
c+=1
l=i
print(c)
| 7 | PYTHON3 |
#155A-I_love_%username%
n=int(input())
list1=[int(x) for x in input().split(' ')]
c=0
for i in range(1,n):
if (list1[i] > (max(list1[:i]))) or (list1[i] < (min(list1[:i]))):
c+=1
print(c)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int min, max, count = 0, a[n];
cin >> a[0];
min = max = a[0];
for (int i = 1; i < n; i++) {
cin >> a[i];
if (a[i] < min) {
min = a[i];
count++;
} else if (a[i] > max) {
count++;
max = a[i];
}
}
cout << count;
return 0;
}
| 7 | CPP |
n=int(input())
ls=input().split()
s=0
mini=int(ls[0])
maxi=int(ls[0])
for i in range(1,len(ls)):
if int(ls[i])<mini:
s+=1
mini=int(ls[i])
elif int(ls[i])>maxi:
s+=1
maxi=int(ls[i])
else:
pass
print(s)
| 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
l1=[l[0]]
for i in range(1,n):
if l[i]>max(l1) or l[i]<min(l1):
l1.append(l[i])
print(len(l1)-1)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int a[10000], n, i, count = 0, min = 0, max = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
min = a[0];
max = a[0];
for (i = 1; i < n; i++) {
if (a[i] > max) {
max = a[i];
count++;
}
if (a[i] < min) {
min = a[i];
count++;
}
}
printf("%d\n", count);
return 0;
}
| 7 | CPP |
n = int(input())
a = list(map(int,input().split()))
p = -10 ** 10
m = 10 ** 10
ans = -2
for val in a:
if val < m:
ans += 1
m = val
if val > p:
ans += 1
p = val
print(max(ans, 0))
| 7 | PYTHON3 |
n=int(input())
l=list(map(int,input().split()))
mx=l[0]
mn=l[0]
c=0
for i in range(1,n):
if l[i]>mx:
c+=1
mx=l[i]
if l[i]<mn:
c+=1
mn=l[i]
print(c) | 7 | PYTHON3 |
'''
Amirhossein Alimirzaei
Telegram : @HajLorenzo
Instagram : amirhossein_alimirzaei
University of Bojnourd
'''
x=int(input())
n=list(map(int,input().split()))
c=0
check=False
for _ in range(1,x):
check = True
for __ in range(_):
if(n[_]>n[__]):
continue
else:
check=False
break
if(check):
c+=1
#print("n : ",n[_])
else:
check=True
for __ in range(_):
if (n[_] < n[__]):
continue
else:
check = False
break
if (check):
c += 1
#print("n : ",n[_])
print(c) | 7 | PYTHON3 |
# I_love_%username%
def amazing(arr):
smol = big = arr[0]
count = 0
for i in arr[1:]:
if (i > big):
count += 1
big = i
elif (i < smol):
count += 1
smol = i
return count
n = int(input())
x = list(map(int, input().rstrip().split()))
print(amazing(x)) | 7 | PYTHON3 |
k = int(input())
c = list(map(int, input().split()))
min_s = c[0]
max_s = c[0]
ans = 0
for i in c[1:]:
if i > max_s:
ans += 1
max_s = i
elif i < min_s:
ans += 1
min_s = i
print(ans) | 7 | PYTHON3 |
n=int(input())
*l,=map(int,input().split())
M=0
m=10001
ans=0
for i in l:
if i>M or i<m:
ans+=1
M=max(M,i)
m=min(m,i)
print(ans-1) | 7 | PYTHON3 |
n = int(input())
a = list(map(int,input().split()))
c = 0
l = [a[0]]
for i in range(1,n):
if a[i] not in l:
l.append(a[i])
ma = a[i]
mi = a[i]
if max(l) == ma or min(l) == mi:
c += 1
print(c) | 7 | PYTHON3 |
n=int(input())
s=input().split()
x=0
while x<len(s):
s[x]=int(s[x])
x=x+1
x=1
y=s[0]
z=s[0]
a=0
while x<len(s):
if s[x]>y:
y=s[x]
a=a+1
elif s[x]<z:
z=s[x]
a=a+1
x=x+1
print(a)
| 7 | PYTHON3 |
n=int(input())
if(n==1):
x=int(input())
print("0")
elif(n==2):
y,z=map(int,input().split())
if(y==z):
print("0")
else:
print("1")
elif(n>2):
l=list(map(int,input().strip().split()))
s=0
for j in range(1,n):
c=d=0
for k in range(0,j):
if(l[j]>l[k]):
c=c+1
elif(l[j]<l[k]):
d=d+1
if(c==j or d==j):
s=s+1
print(s)
| 7 | PYTHON3 |
n = int(input())
num = list(map(int, input().split()))
mn, mx = num[0], num[0]
a = 0
for i in range(1, n):
if mn > num[i]:
mn = num[i]
a += 1
if mx < num[i]:
mx = num[i]
a += 1
print(a) | 7 | PYTHON3 |
s = int(input())
r = list(map(int,input().split()))
mini = r[0]
maxi = r[0]
count = 0
for i in range(1,s):
if r[i]<mini:
count += 1
mini = r[i]
elif r[i] > maxi:
count += 1
maxi = r[i]
print(count)
| 7 | PYTHON3 |
n=int(input())
z=list(map(int,input().split()))
mini=maxi=z[0]
aw=0
for x in z:
if x < mini or x > maxi:
aw+=1
if x < mini:
mini = x
else:
maxi = x
print(aw) | 7 | PYTHON3 |
n = int(input())
d = list(map(int, input().split()))
b = []
c = 0
for i in range(n):
if i == 0:
b.append(d[i])
else:
b.append(d[i])
if b[-1] > max(b[:-1]) or b[-1] < min(b[:-1]):
c += 1
print(c)
| 7 | PYTHON3 |
a = int(input())
n = 0
s = [int(i) for i in input().split()]
mi = s[0]
ma = s[0]
for i in range(a):
if s[i] < mi:
mi = s[i]
n+=1
elif s[i] > ma:
ma = s[i]
n+=1
print(n)
| 7 | PYTHON3 |
n = int(input())
points = list(map(int, input().split()))
max = min = points[0]
amazed = 0
for p in points:
if p > max:
amazed += 1
max = p
if p < min:
amazed += 1
min = p
print(amazed)
| 7 | PYTHON3 |
n = int(input())
a = list(map(int, input().split()))
minn = a[0]
maxx = a[0]
sum = 0
for i in range(len(a)):
if a[i] > maxx:
maxx = a[i]
sum += 1
if a[i] < minn:
minn = a[i]
sum += 1
print(sum) | 7 | PYTHON3 |
#155A
size=int(input())
counter=0
list_=input().split()
for i in range(0,size):
list_[i]=int(list_[i])
max=min=list_[0]
for i in range(1,size):
if list_[i]>max:
counter+=1
max=list_[i]
#print("iteration:flag1",i)
#print("value of max:",max)
if list_[i]<min:
counter+=1
min=list_[i]
#print("iteration:flag2",i)
#print("value of min:",min)
print(counter)
| 7 | PYTHON3 |
n = int(input())
s = [int(i) for i in input().split()]
res = 0
mmin = s[0]
mmax = s[0]
for i in s:
if i > mmax:
res += 1
mmax = i
elif i < mmin:
res += 1
mmin = i
print(res)
| 7 | PYTHON3 |
n = input()
s = input()
s = s.split(' ')
s = list(map(int, s))
n = int(n)
maxx = minn = s[0]
out = 0
for i in range(1, n):
if s[i] > maxx or s[i] < minn:
out += 1
if s[i] > maxx:
maxx = s[i]
elif s[i] < minn:
minn = s[i]
print(out)
| 7 | PYTHON3 |
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
m=0
for i in range(1,n):
x=a[i]
b.append(x)
if (min(b)==x or max(b)==x) and b.count(x)==1:
m+=1
print(m) | 7 | PYTHON3 |
num_contests = int(input())
contests_points = list(map(int, input().split()))
max = contests_points[0]
min = contests_points[0]
amazings = 0
for contest in range(1, num_contests):
if contests_points[contest] > max:
amazings += 1
max = contests_points[contest]
if contests_points[contest] < min:
amazings += 1
min = contests_points[contest]
print(amazings)
| 7 | PYTHON3 |
n = int(input(''))
c = list(map(int, input().split()[:n]))
dic = dict()
z = 0
ma = c[0]
mi = c[0]
if n == 1:
print(z)
else:
for i in range(1,n):
if c[i] < ma:
ma = c[i]
z+=1
if c[i] > mi:
mi = c[i]
z += 1
print(z)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
int main() {
int n, max, min, k = 0;
scanf("%d", &n);
int a[n];
scanf("%d", &a[0]);
max = a[0];
min = max;
for (int i = 1; i <= n; i++) {
if (i < n) {
scanf("%d", &a[i]);
}
if (a[i - 1] > max) {
max = a[i - 1];
k++;
}
if (a[i - 1] < min) {
min = a[i - 1];
k++;
}
}
printf("%d", k);
return 0;
}
| 7 | CPP |
n=int(input())
l=list(map(int,input().split()))
c=0
max=l[0]
min=l[0]
for i in range(0,len(l)):
if(l[i]>max):
max=l[i]
c=c+1
if(l[i]<min):
min=l[i]
c=c+1
print(c) | 7 | PYTHON3 |
n = int(input())
l = list(map(int, input().split(' ')))
o = 0
for i in range(1, len(l)):
k = (l[i])
if l[i] == max(l[0:i + 1]) or l[i] == min(l[0:i + 1]):
if not l[i] in l[0:i]:
o += 1
else:
continue
print(o)
| 7 | PYTHON3 |
n=int(input())
scores=list(map(int,input().split(" ")))
c=0
s=l=scores[0]
for scores in scores[1:]:
if scores>l:
l=scores
c+=1
elif scores<s:
c+=1
s=scores
print(c) | 7 | PYTHON3 |
n = int(input())
r = [int(i) for i in input().split()]
total = 0
for i in range(1,n):
if r[i] < min(i for i in r[0:i]):
total += 1
elif r[i] >max(k for k in r[0:i]):
total += 1
print(total)
| 7 | PYTHON3 |
def main():
n = int(input())
s = list(map(int, input().split()))
maxv = s[0]
minv = s[0]
count = 0
for i in s:
if i > maxv:
maxv = i
count += 1
if i < minv:
minv = i
count += 1
print(count)
if __name__ == '__main__':
main()
| 7 | PYTHON3 |
n = int(input())
m =[int (x) for x in input().split()]
min1 = max1 = m[0]
counter = 0
for i in m[1:]:
if(i < min1):
min1 = i
counter+=1
if(i > max1):
max1 = i
counter+=1
print(counter)
| 7 | PYTHON3 |
n = int(input())
a = list(input().split())
wonderfull = 0
for i in range(n):
m = 0
b = 0
for k in range(i):
if int(a[i]) > int(a[k]):
b += 1
elif int(a[i]) < int(a[k]):
m += 1
if m == 0 and b == i:
wonderfull += 1
elif m == i and b == 0:
wonderfull += 1
print(wonderfull-1)
| 7 | PYTHON3 |
# SHRi GANESHA author: Kunal Verma #
import os
from collections import Counter, defaultdict
from io import BytesIO, IOBase
import math
import sys
class SortedList:
def __init__(self, iterable=None, _load=200):
"""Initialize sorted list instance."""
if iterable is None:
iterable = []
values = sorted(iterable)
self._len = _len = len(values)
self._load = _load
self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
self._list_lens = [len(_list) for _list in _lists]
self._mins = [_list[0] for _list in _lists]
self._fen_tree = []
self._rebuild = True
def _fen_build(self):
"""Build a fenwick tree instance."""
self._fen_tree[:] = self._list_lens
_fen_tree = self._fen_tree
for i in range(len(_fen_tree)):
if i | i + 1 < len(_fen_tree):
_fen_tree[i | i + 1] += _fen_tree[i]
self._rebuild = False
def _fen_update(self, index, value):
"""Update `fen_tree[index] += value`."""
if not self._rebuild:
_fen_tree = self._fen_tree
while index < len(_fen_tree):
_fen_tree[index] += value
index |= index + 1
def _fen_query(self, end):
"""Return `sum(_fen_tree[:end])`."""
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
x = 0
while end:
x += _fen_tree[end - 1]
end &= end - 1
return x
def _fen_findkth(self, k):
"""Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`)."""
_list_lens = self._list_lens
if k < _list_lens[0]:
return 0, k
if k >= self._len - _list_lens[-1]:
return len(_list_lens) - 1, k + _list_lens[-1] - self._len
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
idx = -1
for d in reversed(range(len(_fen_tree).bit_length())):
right_idx = idx + (1 << d)
if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
idx = right_idx
k -= _fen_tree[idx]
return idx + 1, k
def _delete(self, pos, idx):
"""Delete value at the given `(pos, idx)`."""
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len -= 1
self._fen_update(pos, -1)
del _lists[pos][idx]
_list_lens[pos] -= 1
if _list_lens[pos]:
_mins[pos] = _lists[pos][0]
else:
del _lists[pos]
del _list_lens[pos]
del _mins[pos]
self._rebuild = True
def _loc_left(self, value):
"""Return an index pair that corresponds to the first position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
lo, pos = -1, len(_lists) - 1
while lo + 1 < pos:
mi = (lo + pos) >> 1
if value <= _mins[mi]:
pos = mi
else:
lo = mi
if pos and value <= _lists[pos - 1][-1]:
pos -= 1
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value <= _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def _loc_right(self, value):
"""Return an index pair that corresponds to the last position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
pos, hi = 0, len(_lists)
while pos + 1 < hi:
mi = (pos + hi) >> 1
if value < _mins[mi]:
hi = mi
else:
pos = mi
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value < _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def add(self, value):
"""Add `value` to sorted list."""
_load = self._load
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len += 1
if _lists:
pos, idx = self._loc_right(value)
self._fen_update(pos, 1)
_list = _lists[pos]
_list.insert(idx, value)
_list_lens[pos] += 1
_mins[pos] = _list[0]
if _load + _load < len(_list):
_lists.insert(pos + 1, _list[_load:])
_list_lens.insert(pos + 1, len(_list) - _load)
_mins.insert(pos + 1, _list[_load])
_list_lens[pos] = _load
del _list[_load:]
self._rebuild = True
else:
_lists.append([value])
_mins.append(value)
_list_lens.append(1)
self._rebuild = True
def discard(self, value):
"""Remove `value` from sorted list if it is a member."""
_lists = self._lists
if _lists:
pos, idx = self._loc_right(value)
if idx and _lists[pos][idx - 1] == value:
self._delete(pos, idx - 1)
def remove(self, value):
"""Remove `value` from sorted list; `value` must be a member."""
_len = self._len
self.discard(value)
if _len == self._len:
raise ValueError('{0!r} not in list'.format(value))
def pop(self, index=-1):
"""Remove and return value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
value = self._lists[pos][idx]
self._delete(pos, idx)
return value
def bisect_left(self, value):
"""Return the first index to insert `value` in the sorted list."""
pos, idx = self._loc_left(value)
return self._fen_query(pos) + idx
def bisect_right(self, value):
"""Return the last index to insert `value` in the sorted list."""
pos, idx = self._loc_right(value)
return self._fen_query(pos) + idx
def count(self, value):
"""Return number of occurrences of `value` in the sorted list."""
return self.bisect_right(value) - self.bisect_left(value)
def __len__(self):
"""Return the size of the sorted list."""
return self._len
def __getitem__(self, index):
"""Lookup value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
return self._lists[pos][idx]
def __delitem__(self, index):
"""Remove value at `index` from sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
self._delete(pos, idx)
def __contains__(self, value):
"""Return true if `value` is an element of the sorted list."""
_lists = self._lists
if _lists:
pos, idx = self._loc_left(value)
return idx < len(_lists[pos]) and _lists[pos][idx] == value
return False
def __iter__(self):
"""Return an iterator over the sorted list."""
return (value for _list in self._lists for value in _list)
def __reversed__(self):
"""Return a reverse iterator over the sorted list."""
return (value for _list in reversed(self._lists) for value in reversed(_list))
def __repr__(self):
"""Return string representation of sorted list."""
return 'SortedList({0})'.format(list(self))
def primes(n):
z=[]
x=1
while (n%2==0):
n=n//2
z.append(2)
for i in range(3, math.ceil(math.sqrt(n))+1, 2):
x=1
while n%i==0:
n=n//i
z.append(i)
if n>2:
z.append(n)
w= Counter(z)
x=[1 for i in range(max(w.values())) ]
for j in w:
for q in range(w[j]):
x[q]*=j
return x[::-1]
def main():
n=int(input())
a=[int(X) for X in input().split()]
x=[]
an=1
for i in a:
if len(x):
if i>x[-1]:
an+=1
elif i<x[0]:
an+=1
x.append(i)
x.sort()
print(an-1)
# Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == '__main__':
main() | 7 | PYTHON3 |
x = int(input())
p = input().split()
p = [int(char) for char in p]
ans = 0
max_score = 0
min_score = 0
for i in range(x):
if i == 0:
max_score = p[i]
min_score = p[i]
else:
if p[i] > max_score:
max_score = p[i]
ans += 1
elif p[i] < min_score:
min_score = p[i]
ans += 1
print(ans)
| 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];
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 = 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 |
n = int(input())
count = 0
l = list(map(int,input().split()))
mxm = mnm = l[0]
for i in range(1,n):
if l[i] > mxm or l[i] < mnm:
count += 1
mxm = max(mxm,l[i])
mnm = min(mnm,l[i])
print(count) | 7 | PYTHON3 |
n = int(input())
countr =0
l = [int(i) for i in input().split()]
for i in range(1,n):
if l[i] > max(l[0:i]) or l[i]< min(l[0:i]):
countr = countr + 1
print(countr) | 7 | PYTHON3 |
n=int(input())
a=[int(i) for i in input().split()]
s=0
c=a[0]
d=a[0]
for i in range(0,n):
if a[i]>c:
c=a[i]
s=s+1
if a[i]<d:
d=a[i]
s=s+1
print(s)
| 7 | PYTHON3 |
input();f=1;c=0
for x in map(int,input().split()):
if f:
a=b=x
f=0
else:
if x<a or x>b:
c+=1
a=min(a,x)
b=max(b,x)
print(c)
| 7 | PYTHON3 |
n=int(input())
max=-1
min=10001
count=0
z=input().split()
for x in z:
x=int(x)
if x > max :
count+=1
max=x
if x < min :
count+=1
min=x
print(count-2) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, max, min, a[1000000], count = 0, i;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a[i];
}
max = a[0];
min = a[0];
for (i = 1; i < n; i++) {
if (a[i] > max) {
max = a[i];
count++;
} else if (a[i] < min) {
min = a[i];
count++;
}
}
cout << count;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
| 7 | CPP |
n=input()
n=int(n)
score=[int(x) for x in input().split()]
amazing=0
for i in range(1,n):
if (score[i] > max(score[:i])) or (score[i] < min(score[:i])):
amazing=amazing+1
print(amazing)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const double PI = M_PI;
const int INF = -1 * 1e9;
const long long limit = -1 * 1e16;
const int MOD1 = 1e9 + 711;
const int MOD2 = 1e9 + 933;
const int MOD3 = 1e9 + 993;
const int maxn = 1e6 + 100;
int main() {
cout.tie(0);
cin.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin >> n;
int ans = 0;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int mi = a[0], mx = a[0];
for (int i = 1; i < n; ++i) {
if (a[i] > mx) {
mx = a[i];
++ans;
}
if (a[i] < mi) {
mi = a[i];
++ans;
}
}
cout << ans;
cerr << "\n\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
return 0;
}
| 7 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int input;
int count = 0;
vector<int> ar;
for (int i = 0; i < n; i++) {
cin >> input;
ar.push_back(input);
}
for (int i = 1; i < n; i++) {
auto max_it = max_element(ar.begin(), ar.begin() + i);
auto min_it = min_element(ar.begin(), ar.begin() + i);
int min = *min_it;
int max = *max_it;
if (ar[i] > max || ar[i] < min) count++;
}
cout << count;
return 0;
}
| 7 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.