s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s520266148 | p03745 | u298520807 | 1590461655 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 392 | from otsutil.funcs import parg
_ = input()
A = map(int, input().split())
prev = next(A)
up = None
count = 1
for i in A:
if prev < i:
if up is None:
up = True
elif not up:
count += 1
up = None
else:
if up is None:
up = False
elif up:... |
s876069676 | p03745 | u805431781 | 1590361645 | Python | Python (3.4.3) | py | Runtime Error | 79 | 14252 | 749 | N = int(input())
A = list(map(int,input().split()))
if A[0] > A[1]:
status = 'dec'
elif A[1] > A[0]:
status = 'inc'
else:
status = 'equal'
cnt = 0
for i in range(2,N):
if status == 'dec' and A[i] > A[i-1]:
cnt += 1
status = 'none'
elif status == 'inc' and A[i] < A[i-1]:
... |
s607043913 | p03745 | u846226907 | 1590267334 | Python | Python (3.4.3) | py | Runtime Error | 103 | 14480 | 858 | import sys
read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)
#N,*A = map(int,read().split())
N = int(input())
A = list(map(int,input().split()))
#増減のメモ
# A[i] > A[i+1] : 1
# A[i] < A[i+1] : -1
# A[i] == A[i+1] :... |
s565753836 | p03745 | u494037809 | 1590188805 | Python | Python (3.4.3) | py | Runtime Error | 155 | 12408 | 1957 | import numpy as np
N, L, T = map(int, input().split())
xw_list = []
for n in range(N):
xw_list.append(list(map(int, input().split())))
dic = {k : v for k, v in enumerate(xw_list)}
sort_dic = sorted(dic.items(), key=lambda x:x[1])
# 1 : 時計回り、2 : 反時計回り
for t in range(T):
for n in range(N):
t_xw = s... |
s309316489 | p03745 | u787059958 | 1590096652 | Python | Python (3.4.3) | py | Runtime Error | 127 | 14484 | 626 | n = int(input())
L = list(map(int, input().split()))
cnt = 0
larger = 1
smaller = -1
d = [0] * (n - 1)
if (L[0] > L[1]):
d[0] = -1
elif (L[0] < L[1]):
d[0] = 1
cnt = 1
for i in range(n):
if (i == 0):
continue
elif (i == n - 1):
break
else:
if (L[i] < L[i + 1] and d[i - 1] ... |
s974937667 | p03745 | u442877951 | 1590009244 | Python | Python (3.4.3) | py | Runtime Error | 105 | 14252 | 281 | N = int(input())
A = list(map(int,input().split()))
count = 1
for i in range(1,N-1):
if A[i-1] > A[i]:
up,down = 0,1
elif A[i-1] < A[i]:
up,down = 1,0
if up == 1 and A[i] > A[i+1]:
count += 1
elif down == 1 and A[i] < A[i+1]:
count += 1
print(count)
|
s788968749 | p03745 | u846226907 | 1589905661 | Python | Python (3.4.3) | py | Runtime Error | 120 | 12992 | 603 | import sys
read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)
N = int(readline())
A = list(map(int,readline().split()))
res = 0
in_i = 0
de_i = 0
i = 0
while i < N-1:
for j in range(i+1,N):
if A[j] >= A[j-... |
s984572817 | p03745 | u846226907 | 1589904711 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 12992 | 543 | import sys
read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)
N = int(readline())
A = list(map(int,readline().split()))
res = 0
in_i = 0
de_i = 0
i = 0
while i <= N-1:
for j in range(i+1,N):
if A[j] >= A[j... |
s449990421 | p03745 | u134019875 | 1589866019 | Python | Python (3.4.3) | py | Runtime Error | 88 | 14480 | 726 | n = int(input())
L = list(map(int, input().split()))
cnt = 1
state = None
i = 1
while i < n:
if state is None:
if L[i] > L[i - 1]:
state = 'up'
elif L[i] < L[i - 1]:
state = 'down'
i += 1
else:
if state == 'up':
while L[i] >= L[i - 1]:
... |
s250474773 | p03745 | u993268357 | 1589839073 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 407 | n = int(input().split())
num_list = [int(i) for i in input().split()]
if len(num_list)==1:
print(1)
else:
res = 1
flag = None
pre = num_list[0]
for i in num_list[1:]:
if pre > i and not flag:
flag = 'down'
elif pre < i and not flag:
flag = 'up'
elif (pre > i and flag=='up') o... |
s923564152 | p03745 | u860002137 | 1589741054 | Python | Python (3.4.3) | py | Runtime Error | 324 | 23136 | 474 | import sys
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
if len(A)==0:
print(1)
sys.exit()
A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)
ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
if flg==1:
prev = sq[i]
flg = 0
... |
s215185437 | p03745 | u860002137 | 1589740962 | Python | Python (3.4.3) | py | Runtime Error | 337 | 23116 | 420 | import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)
ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
if flg==1:
prev = sq[i]
flg = 0
continue
current = sq[i]
if (prev * current)... |
s776437793 | p03745 | u860002137 | 1589740820 | Python | Python (3.4.3) | py | Runtime Error | 317 | 23084 | 370 | import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
sq = np.diff(A)
ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
if flg==1:
prev = sq[i]
flg = 0
continue
current = sq[i]
if (prev * current) >= 0:
continue
else:
ans += 1
... |
s468992298 | p03745 | u268516119 | 1589556453 | Python | PyPy3 (2.4.0) | py | Runtime Error | 228 | 62704 | 479 | N = int(input())
A = [int(hoge) for hoge in input().split()]
ans = 1
cur = A[0]
Decided = A[0] != A[1]
Flat = A[0] == A[1]
Up = A[0] < A[1]
for n in range(1,N):
if Decided:
if (A[n]>=cur) == Up:#数列が続く
cur = A[n]
else:
cur = A[n]
Up = 1 - Up
Decided = ... |
s847317650 | p03745 | u509739538 | 1589339194 | Python | Python (3.4.3) | py | Runtime Error | 122 | 15324 | 2635 | import math
import queue
from collections import defaultdict
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for i in range(3,math.floor(n//... |
s977337268 | p03745 | u509739538 | 1589339042 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 15320 | 2657 | import math
import queue
from collections import defaultdict
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def factorization(n):
res = []
if n%2==0:
res.append(2)
for i in range(3,math.floor(n//... |
s623498491 | p03745 | u912652535 | 1588776851 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 23128 | 303 |
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
ret = 0
i = 0
while i < len(a):
j = i
while j < n -1 and a[j] <= a[j+1]:
j += 1
h = i
while h < n - i and a[h] >= a[h +1 ]:
h += 1
i = max(h,j) + 1
ret += 1
print(ret)
|
s341503409 | p03745 | u056358163 | 1588729544 | Python | Python (3.4.3) | py | Runtime Error | 542 | 23132 | 343 | import numpy as np
N = int(input())
A = list(map(int, input().split()))
a_ = A[1]
d_ = np.sign(A[1] - A[0])
turn_p = 0
for a in A[2:]:
d = np.sign(a - a_)
#print(a, d, d_, turn_p)
if d != 0:
if d_ == 0:
d_ = d
elif d_ != d:
turn_p += 1
d_ = 0
a_ = a
... |
s241431234 | p03745 | u086503932 | 1588657958 | Python | Python (3.4.3) | py | Runtime Error | 75 | 14252 | 397 | #!/usr/bin/env python3
import sys
def main():
N = int(input())
A = list(map(int, input().split()))
ans = 0
i = 0
while 1:
if A[i] <= A[i+1] <= A[i+2] or A[i] >= A[i+1] >= A[i+2]:
i += 1
else:
ans += 1
i += 2
if i > N - 3:
ans +... |
s956493735 | p03745 | u375695365 | 1588171421 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14428 | 713 | n=int(input())
a=list(map(int,input().split()))
ans=1
now=a[0]
start=1
while now==a[start]:
start+=1
if a[0]<a[start]:#増加
jugh=1
else:#現象
jugh=2
#print(start,jugh)
i=start
while i<n:
if jugh==0:
while now==a[start]:
start+=1
if now<a[start]:#増加
jugh=1
else... |
s594112150 | p03745 | u678167152 | 1588083220 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 528 | N = int(input())
A = list(map(int, input().split()))
def solve(N,A):
liss = []
lis = []
lis.append(A[0])
a = A[0]
for i in range(1,N):
if len(lis)==1 or prev==0:
if A[i]>a:
prev = 1
elif A[i]<a:
prev = -1
else:
... |
s909820907 | p03745 | u145950990 | 1588040472 | Python | Python (3.4.3) | py | Runtime Error | 83 | 14252 | 185 | n = int(input())
a = list(map(int,input().split()))
c = 1
x = a[1]-a[0]
for i in range(1,n-1):
y = a[i+1]-a[i]
if x*y<0:
if i<n-2:x = a[i+2]-a[i+1]
c+=1
print(c) |
s109794536 | p03745 | u145950990 | 1588040384 | Python | Python (3.4.3) | py | Runtime Error | 84 | 14252 | 186 | n = int(input())
a = list(map(int,input().split()))
c = 1
x = a[1]-a[0]
for i in range(1,n-1):
y = a[i+1]-a[i]
if x*y<0:
if i!=n-2:x = a[i+2]-a[i+1]
c+=1
print(c) |
s844986043 | p03745 | u816631826 | 1587939509 | Python | Python (3.4.3) | py | Runtime Error | 1406 | 142640 | 313 | n=int(input())
a=list(map(int,input().split()))
a+=[0]
a=[a[i] for i in range(n) if a[i]!=a[i+1]]
s=0
while a:
n=len(a)
print(a)
if n==1:
s+=1
break
else:
d=a[0]-a[1]>0
for i in range(n-1):
if d==(a[i]-a[i+1]<0):
a=a[i+1:]
break
else:
a=[]
s+=1
print(s) |
s429074710 | p03745 | u903005414 | 1587776598 | Python | Python (3.4.3) | py | Runtime Error | 350 | 23128 | 418 | import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
v = A[1:] - A[:-1]
# print(v)
cnt = 0
i = 0
while i <= len(v) - 1:
# print('i', i)
if v[i] * v[i + 1] < 0:
cnt += 1
i += 1
i += 1
ans = cnt + 1
print(ans)
# 単調非減少 : v[i + 1] - v[i] >= 0
# 単調非増加 : v[i + 1] - ... |
s977154945 | p03745 | u086503932 | 1587604192 | Python | Python (3.4.3) | py | Runtime Error | 91 | 14224 | 302 | N = int(input())
A = list(map(int, input().split()))
ans = 0
i = 0
while i < N-3:
tmp = i
while (A[tmp+1]-A[tmp])*(A[tmp+2]-A[tmp+1])>=0:
tmp += 1
if tmp == N-3:
break
ans += 1
i = tmp+2
else:
if (A[N-2]-A[N-3])*(A[N-1]-A[N-2])>=0:
ans += 1
else:
ans += 2
print(ans) |
s503634822 | p03745 | u086503932 | 1587604099 | Python | Python (3.4.3) | py | Runtime Error | 91 | 14224 | 302 | N = int(input())
A = list(map(int, input().split()))
ans = 0
i = 0
while i < N-3:
tmp = i
while (A[tmp+1]-A[tmp])*(A[tmp+2]-A[tmp+1])>=0:
tmp += 1
if tmp == N-3:
break
ans += 1
i = tmp+2
else:
if (A[N-2]-A[N-3])*(A[N-1]-A[N-3])>=0:
ans += 1
else:
ans += 2
print(ans) |
s427545144 | p03745 | u993310962 | 1587498885 | Python | Python (3.4.3) | py | Runtime Error | 113 | 14480 | 919 | def main():
n=int(input())
a=list(map(int, input().split()))
ud=[]
ans=1
cnt=[0,0]
for i in range(n-1):
if a[i]==a[i+1]:
ud.append('eq')
elif a[i]<a[i+1]:
ud.append('up')
elif a[i]>a[i+1]:
ud.append('down')
if ud[0]=='up':
c... |
s394200638 | p03745 | u000349418 | 1587264481 | Python | Python (3.4.3) | py | Runtime Error | 100 | 14480 | 648 | n=int(input());A=list(map(int,input().split(' ')))
if n <= 2:
ans = 1
else:
ans = 1;i = 2;l = 1
if A[0]<A[1]:
state = 'p'
elif A[0]>A[1]:
state = 'n'
else:
state = '0'
while i < n:
if A[i] > A[i-1]:
if state == 'n' and l != 1:
ans += 1
... |
s781357785 | p03745 | u453683890 | 1587243809 | Python | Python (3.4.3) | py | Runtime Error | 1129 | 394668 | 623 | def solve(ary):
prev = ary[0]
mem = "equal"
for i in ary:
if prev > i:
mem = "minus"
break
elif prev < i:
mem = "plus"
break
if mem == "minus":
return M(ary)
elif mem == "plus":
return P(ary)
else:
return 1
def M(ary):
prev = ary[0]
for i in range(len(ary)):
... |
s643176642 | p03745 | u380995377 | 1587090475 | Python | PyPy3 (2.4.0) | py | Runtime Error | 273 | 59500 | 1822 | import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in ran... |
s080795212 | p03745 | u380995377 | 1587089869 | Python | PyPy3 (2.4.0) | py | Runtime Error | 275 | 59500 | 1798 | import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in ran... |
s836471977 | p03745 | u944643608 | 1587005928 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 508 | N = int(input())
A = list(map(int, input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
tmp = A[i]
if (up == 0) and (down == 0):
if tmp > before:
up = 1
before = tmp
elif tmp < before:
down = 1
before = tmp
else:
continue
elif up == 1:
... |
s769203347 | p03745 | u944643608 | 1587005764 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 506 | N = int(input())
A = list(map(int,input().split()))
count = 0
up = 0
down = 0
before = A[0]
tmp = 0
for i in range(1,N):
tmp = A[i]
if (up == 0) and (down == 0):
if tmp > before:
up = 1
before = tmp
elif tmp < before:
down = 1
before = tmp
else:
continue
elif up == 1:
... |
s177182062 | p03745 | u151005508 | 1586695939 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 14252 | 419 | N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N - 1):
if A[i] == A[i + 1]:
A[i] = '#'
cnt += 1
for _ in range(cnt):
A.remove('#')
#print(A)
if A[0] < A[1]:
plus = 1
else:
plus = -1
i = 1
ans = 1
while i < len(A) - 1:
if A[i-1] < A[i] < A[i+1] or A[i... |
s997090645 | p03745 | u151005508 | 1586695894 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 14252 | 418 | N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N - 1):
if A[i] == A[i + 1]:
A[i] = '#'
cnt += 1
for _ in range(cnt):
A.remove('#')
print(A)
if A[0] < A[1]:
plus = 1
else:
plus = -1
i = 1
ans = 1
while i < len(A) - 1:
if A[i-1] < A[i] < A[i+1] or A[i-... |
s303626860 | p03745 | u174603263 | 1586672127 | Python | Python (3.4.3) | py | Runtime Error | 85 | 16344 | 1124 | import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, asc... |
s717433127 | p03745 | u174603263 | 1586671787 | Python | Python (3.4.3) | py | Runtime Error | 84 | 16324 | 966 | import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, asc... |
s930919639 | p03745 | u174603263 | 1586671373 | Python | Python (3.4.3) | py | Runtime Error | 97 | 16396 | 948 | import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, asc... |
s955146828 | p03745 | u174603263 | 1586671340 | Python | Python (3.4.3) | py | Runtime Error | 168 | 16328 | 959 | import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, asc... |
s376804597 | p03745 | u279493135 | 1586668769 | Python | Python (3.4.3) | py | Runtime Error | 128 | 16324 | 941 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import groupby, accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_... |
s840700343 | p03745 | u644972721 | 1586179621 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14636 | 528 | from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1):
if a[i] != a[i + 1]:
b.append(a[i])
if b[len(b) - 1] != a[n - 1]:
b.append(a[n - 1])
l = len(b)
m = 0
ans = 1
for i in range(l - 1):
if m == 0:
if b[i] < b[i + 1]:
m ... |
s867547119 | p03745 | u363074342 | 1585791841 | Python | Python (3.4.3) | py | Runtime Error | 87 | 14480 | 862 | N = int(input())
A = list(map(int,input().split()))
ans = 1
re = 0
for i in range(N-1):
if A[i+1] > A[i]:
dire = '<'
break
if A[i+1] < A[i]:
dire = '>'
break
else:
dire = '='
if dire != '=':
for i in range(2,N,1):
#print()
if re == 0:
... |
s441786836 | p03745 | u293198424 | 1585700129 | Python | PyPy3 (2.4.0) | py | Runtime Error | 218 | 62832 | 361 | N = int(input())
a = [int(i) for i in input().split()]
result = 1
delta = 0
for i in range(1,n) :
if a[i-1] < a[i]:
ndelta = 1
elif a[i-1] > a[i]:
ndelta = -1
else:
ndelta = 0
if delta!= ndelta:
result += 1
delta = 0
elif not delta:
delta = nd... |
s025656329 | p03745 | u293198424 | 1585699992 | Python | PyPy3 (2.4.0) | py | Runtime Error | 210 | 62832 | 383 | N = int(input())
a = [int(i) for i in input().split()]
result = 1
delta = 0
for i in range(1,n) :
if a[i-1] < a[i]:
ndelta = 1
elif a[i-1] > a[i]:
ndelta = -1
else:
ndelta = 0
if delta and ndelta and delta != ndelta:
result += 1
delta = 0
elif not del... |
s276127249 | p03745 | u293198424 | 1585689671 | Python | PyPy3 (2.4.0) | py | Runtime Error | 233 | 62832 | 320 | N = int(input())
a = [int(i) for i in input().split()]
count = 0
i = 0
while i < N-2:
if a[i] <= a[i+1]:
if a[i+1] > a[i+2]:
count += 1
i += 1
if a[i] >= a[i+1]:
if a[i+1] < a[i+2]:
count += 1
i += 1
i += 1
print(count+1)
|
s163329068 | p03745 | u770077083 | 1584371877 | Python | Python (3.4.3) | py | Runtime Error | 79 | 14252 | 274 | n = int(input())
a = list(map(int, input().split()))
cnt = 1
increase = a[1] - a[0];
for i in range(2, len(a)):
new_inc = a[i] - a[i-1];
if increase * new_inc < 0:
cnt += 1
increase = 0
elif increase == 0:
increase = new_inc
print(cnt)
|
s620168336 | p03745 | u672475305 | 1583282289 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 661 | n = int(input())
lst = list(map(int,input().split()))
m = -1 #m=1:増加、m=2:減少
if n==1 or n==2:
print(1)
else:
cnt = 0
num = lst[0]
mode = 0
for i in range(1,n):
if mode==0: # 待機
if lst[i]==num:
continue
elif lst[i] > num:
mod... |
s273923830 | p03745 | u857070771 | 1582946596 | Python | Python (3.4.3) | py | Runtime Error | 89 | 14252 | 466 | n=int(input())
*a,=map(int,input().split())
cnt=0
mode=0
for i in range(n-1):
if mode==0:
if a[i]<a[i+1]:
cnt+=1
mode="inc"
elif a[i]>a[i+1]:
cnt+=1
mode="dec"
if a[i]<a[i+1]:
if mode=="inc":
pass
else:
mode=... |
s954549456 | p03745 | u541318412 | 1582820631 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14252 | 625 | n = int(input())
l = list(map(int,input().split()))
def ans(x,L):
ans = 1
flag = 0
tmp = L[0:2]
if tmp[0] < tmp[1]:
flag = 1
elif tmp[0] > tmp[1]:
flag = -1
for i in range(2,n):
tmp.append(L[i])
if len(tmp) == 1 and i == n-1:
pass
elif (flag ... |
s339054120 | p03745 | u541318412 | 1582820551 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14480 | 625 | n = int(input())
l = list(map(int,input().split()))
def ans(x,L):
ans = 1
flag = 0
tmp = L[0:2]
if tmp[0] < tmp[1]:
flag = 1
elif tmp[0] > tmp[1]:
flag = -1
for i in range(2,n):
tmp.append(L[i])
if len(tmp) == 1 and i == n-1:
pass
elif (flag ... |
s415101233 | p03745 | u541318412 | 1582818588 | Python | Python (3.4.3) | py | Runtime Error | 97 | 14484 | 523 | n = int(input())
l = list(map(int,input().split()))
def ans(x,L):
ans = 1
flag = 1
tmp = L[0:3]
if (tmp[0]<tmp[1] and tmp[2]<tmp[1]) or (tmp[0]>tmp[1] and tmp[2]>tmp[1]):
ans += 1
flag = 0
for i in range(3,x):
tmp = tmp[1:3]
tmp.append(L[i])
if (tmp[0]<tmp[1]... |
s315209929 | p03745 | u762420987 | 1582705014 | Python | Python (3.4.3) | py | Runtime Error | 113 | 14252 | 530 | N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
for i in range(1, N):
a, b = array[i], array[i-1]
if b < a:
rels.append("<")
if b > a:
rels.append(">")
if a == b:
rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
rel = rels[i]
if ... |
s852757592 | p03745 | u731436822 | 1582567092 | Python | Python (3.4.3) | py | Runtime Error | 74 | 14224 | 330 | #AGC 013 A - Sorted Arrays
#増加⇔減少に転じる際、Ai+1 - Aiは必ず符号反転することを利用
N = int(input())
A = list(map(int,input().split()))
count = 0
sign = 0
for i in range(N):
if sign == 0:
sign = A[i+1]-A[i]
elif sign*(A[i+1]-A[i]) < 0:
count += 1
sign = 0
print(count) |
s030161933 | p03745 | u441575327 | 1582510478 | Python | Python (3.4.3) | py | Runtime Error | 82 | 14480 | 782 | N = int(input())
A = list(map(int,input().split()))
isBigger = A[0] < A[1]
isEqual = A[0] == A[1]
ans = 0
for i in range(1,N):
if isEqual:
if A[i] < A[i-1]:
isBigger = False
isEqual = False
elif A[i-1] < A[i]:
isBigger = True
isEqual = False
... |
s856027747 | p03745 | u757030836 | 1582467793 | Python | Python (3.4.3) | py | Runtime Error | 75 | 14252 | 246 | N = int(input())
A = list(map(int, input().split()))
ans = 1
up,down = False,False
for i in range(N-1):
if A[i] < A[i+1]:
up = True
elif A[i] > A[i+1]:
down = True
if up and dn:
ans +=1
up,down = False,False
print(ans) |
s438088171 | p03745 | u166340293 | 1582466050 | Python | Python (3.4.3) | py | Runtime Error | 121 | 14252 | 301 | N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
if p[i]!=p[i-1]:
q.append(p[i])
size+=1
j=0
while True:
if j>=size-2:
break
while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
if j>=size-2:
break
j+=1
count+=1
j+=2
print(count) |
s479417277 | p03745 | u166340293 | 1582465750 | Python | Python (3.4.3) | py | Runtime Error | 125 | 14252 | 267 | N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
if p[i]!=p[i-1]:
q.append(p[i])
size+=1
j=0
while True:
if j>=size-3:
break
while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
j+=1
count+=1
j+=2
print(count) |
s218464300 | p03745 | u166340293 | 1582436951 | Python | Python (3.4.3) | py | Runtime Error | 45 | 14252 | 193 | N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
j=0
while True:
if j>=N-2:
break
while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
j+=1
count+=1
j+=2
print(count) |
s973615030 | p03745 | u166340293 | 1582436762 | Python | Python (3.4.3) | py | Runtime Error | 127 | 14252 | 267 | N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
if p[i]!=p[i-1]:
q.append(p[i])
size+=1
j=0
while True:
if j>=size-2:
break
while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
j+=1
count+=1
j+=2
print(count) |
s459385295 | p03745 | u462329577 | 1582343786 | Python | PyPy3 (2.4.0) | py | Runtime Error | 219 | 62704 | 348 | #!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
if (a[1]-a[0]) < 0: flag = -1
else: flag = 1
ans = 1
i = 0
while True:
if flag * (a[i+1]-a[i]) < 0:#増加
ans += 1
flag = -1 * flag
i += 1
i += 1
if i == n-1:
break
elif i == n:
ans += 1
... |
s162315842 | p03745 | u478888559 | 1582343358 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14228 | 476 | N = int(input())
A = list(map(int, input().split()))
que = A[0]
list_plus = False
list_minus = False
que_list = []
for i in A:
if que < i:
list_plus = True
break
elif que > i:
list_minus = True
break
if list_plus:
for i in A:
if A[i] < A[i-1]:
len = i
... |
s145906732 | p03745 | u478888559 | 1582342841 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14228 | 581 | N = int(input())
A = list(map(int, input().split()))
que = 0
list_plus = False
list_minus = False
que_list = []
for i in A:
if que == 0:
que = i
que_list.append(i)
elif que < i:
list_plus = True
que = i
que_list.append(i)
elif que > i:
list_minus = True
... |
s904764846 | p03745 | u747703115 | 1581812448 | Python | Python (3.4.3) | py | Runtime Error | 69 | 14252 | 250 | n = int(input())
A = list(map(int, input().split()))
r = 1
d = A[1]-A[0]
if n>2:
for i in range(2, n):
if d:
if (A[i]-A[i-1])*d<0:
r += 1
d = 0
else:
d = A[i]-A[i-1]
print(r) |
s213108466 | p03745 | u852798899 | 1581566622 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14252 | 331 | n = int(input())
a = list(map(int, input().split()))
count = 0
flag = False
if a[0] >= a[1]:
flag = True
else:
flag = False
for i in range(1, n-1):
if a[i] == a[i+1]:
break
elif a[i] > a[i+1]:
if not flag:
count+=1
flag = False
else:
if flag:
count+=1
flag = True
print... |
s637461686 | p03745 | u541610817 | 1581463384 | Python | Python (3.4.3) | py | Runtime Error | 154 | 14436 | 596 | N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst =[]
for i in range(N - 1):
B_lst.append(A_lst[i + 1] - A_lst[i])
def my_sign(n):
return (n > 0) - (n < 0)
cnt = 1
i = 0
pm = my_sign(B_lst[0])
while True:
if i >= len(B_lst) - 2:
break
else:
if my_sign(B_lst[i + 1]) == 0:... |
s723823868 | p03745 | u541610817 | 1581463239 | Python | Python (3.4.3) | py | Runtime Error | 151 | 14436 | 596 | N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst =[]
for i in range(N - 1):
B_lst.append(A_lst[i + 1] - A_lst[i])
def my_sign(n):
return (n > 0) - (n < 0)
cnt = 1
i = 0
pm = my_sign(B_lst[0])
while True:
if i >= len(B_lst) - 1:
break
else:
if my_sign(B_lst[i + 1]) == 0:... |
s057734054 | p03745 | u541610817 | 1581463050 | Python | Python (3.4.3) | py | Runtime Error | 151 | 14440 | 557 | N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst =[]
for i in range(N - 1):
B_lst.append(A_lst[i + 1] - A_lst[i])
def my_sign(n):
return (n > 0) - (n < 0)
cnt = 1
i = 0
pm = my_sign(B_lst[0])
while True:
if i >= len(B_lst) - 1:
break
else:
if my_sign(B_lst[i + 1]) == 0:... |
s278791239 | p03745 | u762420987 | 1580832170 | Python | PyPy3 (2.4.0) | py | Runtime Error | 172 | 38256 | 689 | N = int(input())
Alist = list(map(int, input().split()))
if N < 3:
print(1)
else:
ans = 1
last = Alist[0]
new_a = [last]
for i in range(N):
now = Alist[i]
if now != last:
new_a.append(now)
last = now
now = "up" if new_a[0] < new_a[1] else "down
f = now
... |
s343192018 | p03745 | u487594898 | 1579676048 | Python | Python (3.4.3) | py | Runtime Error | 97 | 15020 | 252 | N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0
for i in range(1,N+1):
if P[i-1]!=P[i] and flag == 0:
flag = 1
elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
cnt += 1
flag = 0
print(cnt)
|
s908736535 | p03745 | u487594898 | 1579675971 | Python | Python (3.4.3) | py | Runtime Error | 94 | 15020 | 250 | N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0
for i in range(1,N+1):
if P[i-1]!=P[i] and flag == 0:
flag = 1
elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
cnt += 1
flag = 0
print(cnt) |
s519263379 | p03745 | u487594898 | 1579675860 | Python | Python (3.4.3) | py | Runtime Error | 93 | 14224 | 250 | N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0
for i in range(1,N+1):
if P[i-1]!=P[i] and flag == 0:
flag = 1
elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
cnt += 1
flag = 0
print(cnt) |
s527328269 | p03745 | u487594898 | 1579675795 | Python | Python (3.4.3) | py | Runtime Error | 96 | 14252 | 250 | N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0
for i in range(1,N+1):
if P[i-1]!=P[i] and flag == 0:
flag = 1
elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
cnt += 1
flag = 0
print(cnt) |
s026459425 | p03745 | u487594898 | 1579675760 | Python | Python (3.4.3) | py | Runtime Error | 92 | 15020 | 266 | N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0 #flag 0=,1=+,2=-
for i in range(1,N+1):
if P[i-1]!=P[i] and flag == 0:
flag = 1
elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
cnt += 1
flag = 0
print(cnt) |
s166394532 | p03745 | u487594898 | 1579675709 | Python | Python (3.4.3) | py | Runtime Error | 93 | 14252 | 268 | N = int(input())
P = list(map(int,input().split()))
cnt = 1
flag = 0 #flag 0=,1=+,2=-
for i in range(1,N+1):
if P[i-1]!=P[i] and flag == 0:
flag = 1
elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):
cnt += 1
flag = 0
print(cnt)
|
s529705504 | p03745 | u968404618 | 1578594070 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14252 | 342 | n = int(input())
a = list(map(int, input().split()))
ans = 1
x = 0
for i in range(n-1):
if A[i] < A[i+1]:
if x == -1:
ans += 1
x = 0
elif x == 0:
x = 1
elif A[i] > A[i+1]:
if x == 1:
ans += 1
x = 0
elif x == 0:
... |
s172800480 | p03745 | u225388820 | 1577377942 | Python | Python (3.4.3) | py | Runtime Error | 78 | 14480 | 534 | n=int(input())
a=list(map(int,input().split()))
i=0
ans=0
while i<n-1:
if a[i]<a[i+1]:
i+=1
while i<n-1:
if a[i]<=a[i+1]:
i+=1
else:
break
#print(i)
i+=1
ans+=1
elif a[i]>a[i+1]:
i+=1
while i<n-1:
... |
s235975574 | p03745 | u754733706 | 1576784226 | Python | Python (3.4.3) | py | Runtime Error | 103 | 14480 | 645 | num = 0
kazu = 0
N = int(input())
data = list(map(int, input().split()))
kazu = len(data)
kai = 0
toku = kazu - 1
i = 1
if toku <= i:
kai += 1
elif data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if tane !... |
s341178878 | p03745 | u754733706 | 1576784151 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14484 | 628 | num = 0
kazu = 0
N = int(input())
data = list(map(int, input().split()))
kai = 0
toku = kazu - 1
i = 1
if toku <= i:
kai += 1
elif data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if tane != n:
kai ... |
s559793902 | p03745 | u754733706 | 1576784083 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14100 | 638 | data = []
num = 0
kazu = 0
N = int(input())
data = list(map(int, input().split()))
kai = 0
toku = kazu - 1
i = 1
if toku <= i:
kai += 1
elif data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if tane != n:
... |
s673325447 | p03745 | u754733706 | 1576783228 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14480 | 650 | N = int(input())
data = list(map(int, input().split()))
num = 0
kazu = 0
kai = 0
toku = kazu - 1
i = 1
flag = 1
if toku <= i:
kai += 1
flag = 0
elif data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if t... |
s765412427 | p03745 | u754733706 | 1576782872 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 633 | data = list(map(int, input().split()))
num = 0
kazu = 0
kai = 0
toku = kazu - 1
i = 1
flag = 1
if toku <= i:
kai += 1
flag = 0
elif data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if tane != n:
... |
s384878782 | p03745 | u754733706 | 1576781722 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14480 | 643 | num = 0
kazu = 0
n = int(input())
data = list(map(int, input().split()))
kazu = len(data)
kai = 0
toku = kazu - 1
i = 1
if toku <= i:
kai += 1
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if tane != ... |
s270727422 | p03745 | u754733706 | 1576781268 | Python | Python (3.4.3) | py | Runtime Error | 102 | 14480 | 643 | num = 0
kazu = 0
n = int(input())
data = list(map(int, input().split()))
kazu = len(data)
kai = 0
toku = kazu - 1
i = 1
if toku == i:
kai += 1
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
tane = n
i = 2
while i <= kazu - 1:
if data[i] <= data[i - 1]:
n = 0
else:
n = 1
if tane != ... |
s295305916 | p03745 | u691896522 | 1575662170 | Python | Python (3.4.3) | py | Runtime Error | 92 | 14224 | 249 | n = int(input())
a = list(map(int, input().split()))
ans = 0
pre = a[1] - a[0]
i = 2
while i < n:
if pre * (a[i] - a[i-1]) < 0:
ans += 1
i += 1
if i == n:
break
pre = a[i] - a[i-1]
i += 1
print(ans+1)
|
s464464103 | p03745 | u353895424 | 1575604886 | Python | Python (3.4.3) | py | Runtime Error | 112 | 14480 | 698 | n = int(input())
a = list(map(int, input().split()))
if n == 1:
print(1)
# 0減少 1そのまま 2増加
flg = [-1] * n
if a[0] < a[1]:
flg[1] = 2
elif a[0] == a[1]:
flg[1] = 1
elif a[0] > a[1]:
flg[1] = 0
cnt = 0
for i in range(2,n):
if a[i-1] < a[i]:
if flg[i-1] == 0:
flg[i] = 100
... |
s581164488 | p03745 | u353895424 | 1575604408 | Python | Python (3.4.3) | py | Runtime Error | 109 | 14480 | 687 | n = int(input())
a = list(map(int, input().split()))
# 0減少 1そのまま 2増加
flg = [-1] * n
flg.append(-1)
if a[0] < a[1]:
flg[1] = 2
elif a[0] == a[1]:
flg[1] = 1
elif a[0] > a[1]:
flg[1] = 0
cnt = 0
for i in range(2,n):
if a[i-1] < a[i]:
if flg[i-1] == 0:
flg[i] = 100
cnt +=... |
s179960760 | p03745 | u814986259 | 1574633093 | Python | Python (3.4.3) | py | Runtime Error | 105 | 14228 | 339 | N = int(input())
A = list(map(int, input().split()))
diff = [A[i+1] - A[i] for i in range(N-1) if A[i+1]-A[i] != 0]
ans = 1
prev = diff[0]
id = 0
while(id < len(diff)-2):
if (diff[id]*diff[id+1]) < 0:
ans += 1
id += 2
else:
id += 1
if diff[-1]*diff[-2] < 0 and diff[-2]*diff[-3]:
a... |
s325819996 | p03745 | u814986259 | 1574632871 | Python | Python (3.4.3) | py | Runtime Error | 106 | 14224 | 317 | N = int(input())
A = list(map(int, input().split()))
diff = [A[i+1] - A[i] for i in range(N-1) if A[i+1]-A[i] != 0]
ans = 1
prev = diff[0]
id = 0
while(id < len(diff)-2):
if (diff[id]*diff[id+1]) < 0:
ans += 1
id += 2
else:
id += 1
if diff[-1]*diff[-2] < 0:
ans += 1
print(ans)
|
s092596703 | p03745 | u814986259 | 1574632693 | Python | Python (3.4.3) | py | Runtime Error | 121 | 14228 | 277 | N = int(input())
A = list(map(int, input().split()))
diff = [A[i+1] - A[i] for i in range(N-1) if A[i+1]-A[i] != 0]
ans = 1
prev = diff[0]
id = 0
while(id < len(diff)-1):
if (diff[id]*diff[id+1]) < 0:
ans += 1
id += 2
else:
id += 1
print(ans)
|
s917003193 | p03745 | u767664985 | 1574296266 | Python | Python (3.4.3) | py | Runtime Error | 87 | 14440 | 656 | def upper_or_lower(i):
if A[i] < A[i + 1]:
return "upper"
elif A[i] > A[i + 1]:
return "lower"
else:
return upper_or_lower(i + 1)
N = int(input())
A = list(map(int, input().split()))
state = "upper" # state が upper か lower で判定
ans = 1
# i = 0 の処理
if A[0] > A[1]:
state = "low... |
s643484722 | p03745 | u379959788 | 1573342687 | Python | Python (3.4.3) | py | Runtime Error | 75 | 14436 | 636 | # AGC013
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
if A[i] == A[i+1]:
pass
elif A[i] > A[i+1]:
now = "N"
break
else:
now = "P"
break
ans = 1
for i in range(N-1):
if now == "?":
if A[i] == A[i+1]:
pass
elif ... |
s839131128 | p03745 | u740284863 | 1572902996 | Python | Python (3.4.3) | py | Runtime Error | 99 | 15020 | 369 | n = int(input())
l = list(map(int,input().split()))
if l[-1] > l[-2]:
l += [float('Inf')]
else:
l += [-float('Inf')]
ans = 1
i = 1
while i <= n - 1:
if l[i-1] <= l[i] and l[i] <= l[i+1]:
i += 1
elif l[i-1] >= l[i] and l[i] >= l[i+1]:
i += 1
else:
#print(l[i-1],l[i],l[i+1])
... |
s943819648 | p03745 | u027929618 | 1572822442 | Python | PyPy3 (2.4.0) | py | Runtime Error | 242 | 63596 | 361 | N=int(input())
A=list(map(int, input().split()))
m=[]
m.append([A[0]])
j=0
f=True
if A[0] > A[1]:
f=False
for i in range(1,N):
if A[i-1] <= A[i] and f:
m[j].append(A[i])
elif A[i-1] >= A[i] and not f:
m[j].append(A[i])
else:
j+=1
m.append([])
m[j].append(A[i])
if i != N-1:
f=True i... |
s065998726 | p03745 | u638282348 | 1572536264 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 597 | n = input()
iter_ = iter(list(map(int, input().rstrip("\n").split())))
ans = 0
last = next(iter_)
try:
while True:
ans += 1
now = next(iter_)
while now == last:
now = next(iter_)
laststate = (last < now)
state = laststate
print(f"out: {last}, {now}")
... |
s090427050 | p03745 | u638282348 | 1572536195 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 596 | n = input()
iter_ = iter(list(map(int, input().rstrip("\n").split())))
ans = 0
last = next(iter_)
try:
while True:
ans += 1
now = next(iter_)
while now == last:
now = next(iter_)
laststate = (last < now)
state = laststate
print(f"out: {last}, {now}")
... |
s909991456 | p03745 | u598229387 | 1571850104 | Python | Python (3.4.3) | py | Runtime Error | 87 | 14428 | 572 | n=int(input())
a=[int(i) for i in input().split()]
ans=0
def plus_minus(i):
while True:
if a[i]==a[i+1]:
i+=1
continue
if a[i]<a[i+1]:
return 1
if a[i]>a[i+1]:
return -1
check=plus_minus(0)
ans=1
for j in range(n-1):
if check=... |
s100729454 | p03745 | u598229387 | 1571850051 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14252 | 574 | n=int(input())
a=[int(i) for i in input().split()]
ans=0
def plus_minus(i):
while True:
if a[i]==a[i+1]:
i+=1
continue
if a[i]<a[i+1]:
return 1
if a[i]>a[i+1]:
return -1
check=plus_minus(0)
ans=1
for j in range(i,n-1):
if chec... |
s102584348 | p03745 | u598229387 | 1571850008 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14436 | 568 | n=int(input())
a=[int(i) for i in input().split()]
ans=0
def plus_minus(i):
while True:
if a[i]==a[i+1]:
i+=1
continue
if a[i]<a[i+1]:
return 1
if a[i]>a[i+1]:
return -1
plus_minus(0)
ans=1
for j in range(i,n-1):
if check==1:
... |
s210322250 | p03745 | u798818115 | 1571451159 | Python | Python (3.4.3) | py | Runtime Error | 88 | 14252 | 302 | N=int(input())
A=list(map(int,input().split()))
ans=0
pre=A[1]-A[0]
cool=True
for i in range(N-2):
temp=A[i+2]-A[i+1]
if temp==0:
cool=True
continue
elif pre*temp<0 and cool:
ans+=1
cool=False
else:
cool=True
pre=temp
print(ans+1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.