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:
count += 1
up = None
prev = i
print(count)
|
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]:
cnt += 1
status = 'none'
elif status == 'equal' and A[i] > A[i-1]:
status = 'inc'
elif status == 'equal' and A[i] < A[i-1]:
status = 'dec'
elif status == 'none' and A[i] < A[i-1]:
status = 'dec'
elif status == 'none' and A[i] > A[i-1]:
status = 'inc'
elif status == 'none' and A[i] == A[i-1]:
status = 'equal'
print(cnt+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] : 0
x = []
for i in range(N-1):
if A[i] < A[i+1]:
x.append(1)
elif A[i] > A[i+1]:
x.append(-1)
else:
x.append(0)
res = 1 #答え
#print(len(x))
state = x[0] #単調増加 or 単調減少の二種で現在の状態を記録
i = 1
while i < N-1:
if x[i] == state or state == 0:
pass
else:
if i != N -2:
state = x[i+1]
i+=1
res+=1
i+=1
if x[-1] != x[-2] and x[-1] != 0 and x[-2]!= 0 :
print(res+1)
else:
print(res)
|
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 = sort_dic[n][1] # 対象アリ
# 移動
if t_xw[1]==1:
t_xw[0] += 1
else:
t_xw[0] -= 1
# 周回した時の変換
if t_xw[0]<0:
t_xw[0] = L + t_xw[0]
elif t_xw[0]>L:
t_xw[0] = t_xw[0] - L
# 衝突
for n in range(N):
# 座標前後のみで検索
t_xw = sort_dic[n][1] # 対象アリ
if n==0:
next_xw = sort_dic[-1][1] # 前のアリ
# ato_xw = sort_dic[n+1][1] # 後のアリ
elif n==N-1:
next_xw = sort_dic[n-1][1] # 前のアリ
# ato_xw = sort_dic[0][1] # 後のアリ
else:
next_xw = sort_dic[n-1][1] # 前のアリ
# ato_xw = sort_dic[n+1][1] # 後のアリ
# for next_xw in [mae_xw]:
# , ato_xw]:
# 1秒後に同じ場所 → 方向転換
if t_xw[0]==next_xw[0]:
t_xw[1] = next_xw[1]
next_xw[1] = t_xw[1]
# 0.5秒後にすれ違う
if np.abs(t_xw[0]-next_xw[0])==1 and t_xw[1]!=next_xw[1]:
if (t_xw[0]>next_xw[0] or (t_xw[0]==0 and next_xw[0]==L-1)) and t_xw[1]==1:
t_xw[0] -= 1
t_xw[1] = 2
next_xw[0] += 1
next_xw[1] = 1
elif (next_xw[0]>t_xw[0] or (next_xw[0]==0 and t_xw[0]==L-1)) and next_xw[1]==1:
t_xw[0] += 1
t_xw[1] = 1
next_xw[0] -= 1
next_xw[1] = 2
for tup in sorted(sort_dic):
print(tup[1][0]) |
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] >= 0):
d[i] = 1
elif (L[i] > L[i + 1] and d[i - 1] <= 0):
d[i] = -1
elif (L[i] < L[i + 1] and d[i - 1] < 0):
cnt += 1
elif (L[i] > L[i + 1] and d[i - 1] > 0):
cnt += 1
elif (L[i] == L[i + 1]):
continue
print(cnt)
|
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-1]:continue
else:
break
in_i = j
for j in range(i+1,N):
if A[j] <= A[j-1]:continue
else:
break
de_i = j
i = max(de_i,in_i)
res+=1
#print(res)
if (A[-3] - A[-2])*(A[-2] - A[-1]) >= 0: print(res)
else: print(res+1) |
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-1]:continue
else:
break
in_i = j
for j in range(i+1,N):
if A[j] <= A[j-1]:continue
else:
break
de_i = j
i = max(de_i,in_i)
res+=1
print(i)
print(res)
|
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]:
i += 1
if i == n - 1:
print(cnt)
exit()
cnt += 1
i += 1
state = None
else:
while L[i] <= L[i - 1]:
i += 1
if i == n - 1:
print(cnt)
exit()
cnt += 1
i += 1
state = None
print(cnt) |
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') or (pre < i and flag=='down'):
res += 1
flag = None
pre = i
print(res) |
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
continue
current = sq[i]
if (prev * current) > 0:
continue
else:
ans += 1
prev = current
flg = 1
print(ans) |
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) > 0:
continue
else:
ans += 1
prev = current
flg = 1
print(ans) |
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
prev = current
flg = 1
print(ans) |
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 = False
ans += 1
else:
if A[n] != cur:
Up = A[n] > cur
cur = A[n]
Decided = True
print(ans) |
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//2)+1,2):
if n%i==0:
c = 0
for j in res:
if i%j==0:
c=1
if c==0:
res.append(i)
return res
def fact2(n):
p = factorization(n)
res = []
for i in p:
c=0
z=n
while 1:
if z%i==0:
c+=1
z/=i
else:
break
res.append([i,c])
return res
def fact(n):#階乗
ans = 1
m=n
for _i in range(n-1):
ans*=m
m-=1
return ans
def comb(n,r):#コンビネーション
if n<r:
return 0
l = min(r,n-r)
m=n
u=1
for _i in range(l):
u*=m
m-=1
return u//fact(l)
def printQueue(q):
r=qb
ans=[0]*r.qsize()
for i in range(r.qsize()-1,-1,-1):
ans[i] = r.get()
print(ans)
def dq():
return queue.deque()
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1]*n
def find(self, x): # root
if self.parents[x]<0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x==y:
return
if self.parents[x]>self.parents[y]:
x,y = y,x
self.parents[x]+=self.parents[y]
self.parents[y]=x
def size(self,x):
return -1*self.parents[self.find(x)]
def same(self,x,y):
return self.find(x)==self.find(y)
def members(self,x): # much time
root = self.find(x)
return [i for i in range(self.n) if self.find(i)==root]
def roots(self):
return [i for i,x in enumerate(self.parents) if x<0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
x = 1
zero = "0"*n
ans = []
ans.append([0]*n)
for i in range(2**n-1):
ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
x+=1
return ans;
def arrsSum(a1,a2):
for i in range(len(a1)):
a1[i]+=a2[i]
return a1
def maxValue(a,b,v):
v2 = v
for i in range(v2,-1,-1):
for j in range(v2//a+1): #j:aの個数
k = i-a*j
if k%b==0:
return i
return -1
n = readInt()
a = readInts()
ans = 1
i = 0
def plumin(i):
if a[i+1]-a[i]>0:
return 1
elif a[i+1]-a[i]<0:
return -1
else:
return 0
pmarr = []
for i in range(n-1):
x = plumin(i)
if x!=0:
pmarr.append(x)
#print(pmarr)
be = pmarr[0]
for i in range(1,len(pmarr)):
if pmarr[i]==be:
continue
else:
ans+=1
if i+1==len(pmarr):
break
be = pmarr[i+1]
print(ans) |
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//2)+1,2):
if n%i==0:
c = 0
for j in res:
if i%j==0:
c=1
if c==0:
res.append(i)
return res
def fact2(n):
p = factorization(n)
res = []
for i in p:
c=0
z=n
while 1:
if z%i==0:
c+=1
z/=i
else:
break
res.append([i,c])
return res
def fact(n):#階乗
ans = 1
m=n
for _i in range(n-1):
ans*=m
m-=1
return ans
def comb(n,r):#コンビネーション
if n<r:
return 0
l = min(r,n-r)
m=n
u=1
for _i in range(l):
u*=m
m-=1
return u//fact(l)
def printQueue(q):
r=qb
ans=[0]*r.qsize()
for i in range(r.qsize()-1,-1,-1):
ans[i] = r.get()
print(ans)
def dq():
return queue.deque()
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1]*n
def find(self, x): # root
if self.parents[x]<0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self,x,y):
x = self.find(x)
y = self.find(y)
if x==y:
return
if self.parents[x]>self.parents[y]:
x,y = y,x
self.parents[x]+=self.parents[y]
self.parents[y]=x
def size(self,x):
return -1*self.parents[self.find(x)]
def same(self,x,y):
return self.find(x)==self.find(y)
def members(self,x): # much time
root = self.find(x)
return [i for i in range(self.n) if self.find(i)==root]
def roots(self):
return [i for i,x in enumerate(self.parents) if x<0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
x = 1
zero = "0"*n
ans = []
ans.append([0]*n)
for i in range(2**n-1):
ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
x+=1
return ans;
def arrsSum(a1,a2):
for i in range(len(a1)):
a1[i]+=a2[i]
return a1
def maxValue(a,b,v):
v2 = v
for i in range(v2,-1,-1):
for j in range(v2//a+1): #j:aの個数
k = i-a*j
if k%b==0:
return i
return -1
n = readInt()
a = readInts()
ans = 1
i = 0
def plumin(i):
if a[i+1]-a[i]>0:
return 1
elif a[i+1]-a[i]<0:
return -1
else:
return 0
pmarr = []
b= 0
for i in range(n-1):
pmarr.append(plumin(i))
while 0 in pmarr:
pmarr.remove(0)
#print(pmarr)
be = pmarr[0]
for i in range(1,len(pmarr)):
if pmarr[i]==be:
continue
else:
ans+=1
if i+1==len(pmarr):
break
be = pmarr[i+1]
print(ans) |
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
print(turn_p+1)
|
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 += 1
break
print(ans)
if __name__ == '__main__':
main()
|
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:#現象
jugh=2
if jugh==1:
if a[i-1]>a[i]:
jugh=0
ans+=1
now=a[i]
start=i+1
#print(a[i-1],a[i])
else:
if a[i-1]<a[i]:
jugh=0
ans+=1
now=a[i]
start=i+1
#print(a[i-1],a[i])
i+=1
print(ans) |
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:
prev = 0
elif ((A[i]-a)*prev<0:
liss.append(lis)
lis = []
lis.append(A[i])
a = A[i]
liss.append(lis)
ans = len(liss)
return ans
print(solve(N,A)) |
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] - v[i] <= 0
# 折り返し点 : v[i] * v[i + 1] < 0 and v[i + 1] * v[i + 2] < 0
|
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':
cnt[0]=1
elif ud[0]=='down':
cnt[1]=1
for i in range(1,n-1):
if (cnt[0]==cnt[1]==0 or cnt[0]!=0) and ud[i]=='up':
cnt[0]+=1
elif (cnt[0]==cnt[1]==0 or cnt[1]!=0) and ud[i]=='down':
cnt[1]+=1
elif cnt[0]!=0 and ud[i]=='down':
ans+=1
cnt[0]=0
elif cnt[1]!=0 and ud[i]=='up':
ans+=1
cnt[1]=0
elif cnt[0]!=0 and cnt[1]==0 and i==n-2:
ans+=1
elif cnt[1]!=0 and cnt[0]==0 and i==n-2:
ans+=1
print(ans)
if __name__=='__main__':
main() |
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
l = 1
else:
l +=1
state = 'p'
elif A[i] < A[i-1]:
if state == 'p' and l != 1:
ans += 1
l = 1
else:
l += 1
state = 'n'
i += 1
if l == 1:
ans += 1
print(ans) |
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)):
if ary[i] > prev:
return solve(ary[i:])+1
prev = ary[i]
return 1
def P(ary):
prev = ary[0]
for i in range(len(ary)):
if ary[i] < prev:
return solve(ary[i:])+1
prev = ary[i]
return 1
N = int(input())
line = [int(x) for x in input().split(' ')]
print(solve(line)) |
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 range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline
N,L,T = MI()
for_l = []
rev_l = []
final = []
for i in range(N):
if i==0:
x0,w0 = MI()
x,w = x0,w0
else:
x,w = MI()
if w==1:
for_l += [x]
final += [(x+T)%L]
else:
rev_l += [x]
final += [(x-T)%L]
final.sort()
opposite_l = rev_l if w0==1 else for_l
opp_num = len(opposite_l)
cicle = (2*T)//L
res = (2*T)%L
cnt = 0 #i=1のアリが衝突する回数
cnt += opp_num*cicle
if res!=0 and res!=1:
xr = (x0 + res -1)%L if w0==1 else x0
xl = x0 if w0==1 else (x0-res+1)%L
for i in opposite_l:
if xl<=xr and xl<=i<=xr:
cnt += 1
if xl>xr and (i>=xl or i<=xr):
cnt += 1
c = (cnt)%N if w0==1 else (-cnt)%N #x0+Tにくるアリの番号
if w0==1:
c_idx = final.index((x0+T)%L)
else:
c_idx_l = [i for i,v in enumerate(final) if v==(x0-T)%L]
c_idx = c_idx_l[-1]
ans = [-1 for i in range(N)]
ans[c] = final[c_idx]
for i in range(1,N):
ans[(c+i)%N] = final[(c_idx+i)%N]
[print(x) for x in ans]
|
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 range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline
N,L,T = MI()
for_l = []
rev_l = []
final = []
for i in range(N):
if i==0:
x0,w0 = MI()
x,w = x0,w0
else:
x,w = MI()
if w==1:
for_l += [x]
final += [(x+T)%L]
else:
rev_l += [x]
final += [(x-T)%L]
final.sort()
opposite_l = rev_l if w0==1 else for_l
opp_num = len(opposite_l)
cicle = (2*T)//L
res = (2*T)%L
cnt = 0 #i=1のアリが衝突する回数
cnt += opp_num*cicle
if res!=0 and res!=1:
xr = (x0 + res -1)%L if w0==1 else x0
xl = x0 if w0==1 else (x0-res+1)%L
for i in opposite_l:
if xl<=xr and xl<=i<=xr:
cnt += 1
if xl>xr and (i>=xl or i<=xr):
cnt += 1
c = (cnt)%N #x0+Tにくるアリの番号
if w0==1:
c_idx = final.index((x0+T)%L)
else:
c_idx_l = [i for i,v in enumerate(final) if v==(x0-T)%L]
c_idx = c_idx_l[-1]
ans = [-1 for i in range(N)]
ans[c] = final[c_idx]
for i in range(1,N):
ans[(c+i)%N] = final[(c_idx+i)%N]
[print(x) for x in ans] |
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:
if tmp < before:
count += 1
up = 0
before = tmp
elif down = 1:
if tmp > before:
count += 1
down = 0
before = tmp
count += 1
print(count)
|
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:
if tmp < before:
count += 1
up = 0
before = tmp
elif down = 1:
if tmp > before:
count += 1
down = 0
before = tmp
count += 1
print(count)
|
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-1] > A[i] > A[i+1]:
pass
else:
i += 1
ans += 1
i += 1
print(ans)
|
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-1] > A[i] > A[i+1]:
pass
else:
i += 1
ans += 1
i += 1
print(ans)
|
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, ascii_uppercase, digits
from fractions import gcd
from queue import Queue
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
def main():
n = INT()
a = LIST()
p = 0
q = 0
l = []
temp = 0
if a[0] < a[1]:
sign = 1
elif a[0] > a[1]:
sign = -1
else:
sign = 0
for i in range(n-1):
if a[i] < a[i+1] and sign == -1:
p += 1
sign = 1
# print("a")
if temp == 0:
q += 1
temp = 1
elif a[i] > a[i+1] and sign == 1:
q += 1
sign = -1
# print("b")
if temp == 0:
p += 1
temp = 1
# print(p, q)
print(max(p, q) + 1)
if __name__ == '__main__':
main()
|
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, ascii_uppercase, digits
from fractions import gcd
from queue import Queue
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
def main():
n = INT()
a = LIST()
p = 0
q = 0
l = []
sign = (a[1]-a[0]) / abs(a[1]-a[0])
for i in range(n-1):
if a[i] < a[i+1] and sign == -1:
p += 1
sign = 1
#print("a")
elif a[i] > a[i+1] and sign == 1:
q += 1
sign = -1
#print("b")
print(p + 2)
if __name__ == '__main__':
main()
|
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, ascii_uppercase, digits
from fractions import gcd
from queue import Queue
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
def main():
n = INT()
a = LIST()
p = 0
q = 0
l = []
sign = (a[1]-a[0]) / abs(a[1]-a[0])
for i in range(n-1):
if a[i] < a[i+1] and sign == -1:
p += 1
sign *= -1
elif a[i] > a[i+1] and sign == 1:
q += 1
sign *= -1
print(max(p, q) + 1)
if __name__ == '__main__':
main()
|
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, ascii_uppercase, digits
from fractions import gcd
from queue import Queue
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
def main():
n = INT()
a = LIST()
p = 0
q = 0
l = []
sign = (a[1]-a[0]) / abs(a[1]-a[0])
for i in range(n-1):
print(i)
if a[i] < a[i+1] and sign == -1:
p += 1
sign *= -1
elif a[i] > a[i+1] and sign == 1:
q += 1
sign *= -1
print(max(p, q) + 1)
if __name__ == '__main__':
main()
|
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_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
A = LIST()
A = [k for k, g in groupby(A)]
i = 1
ans = 0
while i < N-1:
if A[i-1] < A[i] > A[i+1] or A[i-1] > A[i] < A[i+1]:
ans += 1
i += 1
i += 1
print(ans+1)
|
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 = 1
else:
m = -1
elif m == 1:
if b[i] > b[i + 1]:
ans += 1
m = 0
else:
if b[i] < b[i + 1]:
ans += 1
m = 0
print(ans) |
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:
if dire == '>':
if A[i] <= A[i-1] <= A[i-2]:
re = 0
dire = '>'
else:
ans += 1
re = 1
dire = '<'
elif dire == '<':
if A[i-2] <= A[i-1] <= A[i]:
re = 0
dire = '<'
else:
ans += 1
dire = '>'
re = 1
else:
re = 0
print(ans)
|
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 = ndelta
print(result)
|
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 delta:
delta = ndelta
print(result)
|
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:
mode = 1 # 増加
elif lst[i] < num:
mode = 2 # 減少
elif mode == 1:
if lst[i] < num:
cnt += 1
mode = 0
elif mode == 2:
if lst[i] > num:
cnt += 1
mode = 0
num = lst[i]
print(cnt + 1) |
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=0
elif a[i]>a[i+1]:
if mode=="dec":
pass
else:
mode=0
if mode==0:
print(cnt+1)
else:
prnt(cnt) |
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 == -1 and tmp[-2] < tmp[-1]) or (flag == 1 and tmp[-2] > tmp[-1]):
ans += 1
flag = 0
tmp = [tmp[-1]]
elif flag == 0 and tmp[-2] < tmp[-1]:
flag = 1
elif flag == 0 and tmp[-2] > tmp[-1]:
flag = -1
return(ans)
print(ans(n,l)) |
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 == -1 and tmp[-2] < tmp[-1]) or (flag == 1 and tmp[-2] > tmp[-1]):
ans += 1
flag = 0
tmp = [tmp[-1]]
elif flag == 0 and tmp[-2] < tmp[-1]:
flag = 1
elif flag == 0 and tmp[-2] > tmp[-1]:
flag = -1
return(ans)
print(ans(n,l)) |
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] and tmp[2]<tmp[1] and flag > 0) or (tmp[0]>tmp[1] and tmp[2]>tmp[1] and flag > 0):
ans += 1
flag = 0
else:
flag += 1
return(ans)
print(ans(n,l)) |
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 skip:
skip = False
now = rel
continue
if rel == now or rel == "=":
continue
elif now == "=":
now = rel
else:
skip = True
ans += 1
print(ans) |
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
else:
continue
elif isBigger:
if A[i] < A[i-1]:
ans += 1
if i < N-1:
isBigger = A[i] < A[i+1]
isEqual = A[i] == A[i+1]
else:
break
else:
if A[i-1] < A[i]:
ans += 1
if i < N-1:
isBigger = A[i] < A[i+1]
isEqual = A[i] == A[i+1]
else:
break
ans += 1
print(ans) |
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
break
print(ans)
|
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
break
else:
for i in A:
if A[i] > A[i-1]:
len = i
break
# print(len)
s = N // len
a = N % len
print(s + a)
|
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
que = i
que_list.append(i)
if list_plus:
if list_minus:
len = len(que_list) - 1
break
else:
if list_plus:
len = len(que_list) - 1
break
s = N // len
a = N % len
print(s + a)
|
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(count+1)
|
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:
i += 1
continue
elif pm == my_sign(B_lst[i + 1]) or pm == 0:
pm = my_sign(B_lst[i + 1])
i += 1
continue
else:
cnt += 1
pm = my_sign(B_lst[i + 1])
i +=2
print(cnt)
|
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:
i += 1
continue
elif pm == my_sign(B_lst[i + 1]) or pm == 0:
pm = my_sign(B_lst[i + 1])
i += 1
continue
else:
cnt += 1
pm = my_sign(B_lst[i + 1])
i +=2
print(cnt)
|
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:
i += 1
continue
elif pm == my_sign(B_lst[i + 1]) or pm == 0:
pm = my_sign(B_lst[i + 1])
i += 1
continue
else:
cnt += 1
i +=2
print(cnt)
|
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
for i in range(1, len(new_a)):
if new_a[i - 1] == new_a[i]:
continue
elif new_a[i - 1] < new_a[i]:
if now == "down":
now = "up"
elif new_a[i - 1] > new_a[i]:
if now == "up":
now = "down"
if now != f:
ans += 1
# print(i, now, ans)
print(ans + 1) |
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:
x = -1
print(ans) |
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:
if a[i]>=a[i+1]:
i+=1
else:
break
#print(i)
i+=1
ans+=1
else:
i+=1
if (a[n-2]<a[n-1])!=(a[n-3]<a[n-2]):
ans+=1
print(ans) |
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 != n:
kai += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(kai) |
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 += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(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:
kai += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(kai) |
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 tane != n:
kai += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(kai) |
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:
kai += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(kai) |
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 != n:
kai += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(kai) |
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 != n:
kai += 1
i += 1
if i == kazu:
kai += 1
break
if data[i] <= data[i - 1]:
n = 0
tane = n
else:
n = 1
tane = n
continue
i += 1
tane = n
if i >= kazu:
kai += 1
break
print(kai) |
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
cnt += 1
elif flg[i-1] == 1 or flg[i-1] == 2 or flg[i-1] == 100:
flg[i] = 2
elif a[i-1] == a[i]:
flg[i] = 1
elif a[i-1] > a[i]:
if flg[i-1] == 0 or flg[i-1] == 1 or flg[i-1] == 100:
flg[i] = 0
elif flg[i-1] == 2:
flg[i] = 100
cnt += 1
# print(flg)
print(cnt+1)
|
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 += 1
elif flg[i-1] == 1 or flg[i-1] == 2 or flg[i-1] == 100:
flg[i] = 2
elif a[i-1] == a[i]:
flg[i] = 1
elif a[i-1] > a[i]:
if flg[i-1] == 0 or flg[i-1] == 1 or flg[i-1] == 100:
flg[i] = 0
elif flg[i-1] == 2:
flg[i] = 100
cnt += 1
# print(flg)
print(cnt+1)
|
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]:
ans += 1
print(ans)
|
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 = "lower"
for i in range(2, N):
if (state == "upper") and (A[i - 1] > A[i]):
ans += 1
if i < N - 1:
state = upper_or_lower(i)
elif (state == "lower") and (A[i - 1] < A[i]):
ans += 1
if i < N - 1:
state = upper_or_lower(i)
else:
continue
print(ans)
|
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 A[i] > A[i+1]:
now = "N"
else:
now = "P"
elif now == "P":
if A[i] <= A[i+1]:
pass
else:
ans += 1
now = "?"
else:
if A[i] >= A[i+1]:
pass
else:
ans += 1
now = "?"
print(ans) |
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])
ans += 1
i += 2
print(ans) |
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 if A[i] < A[i+1] else False
print(len(m))
|
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}")
while state == laststate:
last = now
now = next(iter_)
while now == last:
now = next(iter_)
state = (last < now)
print(f"in: {last}, {now}")
last = now
except StopIteration:
print(ans)
|
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}")
while state == laststate:
last = now
now = next(iter_)
while now == last:
now = next(iter_)
state = (last < now)
print(f"in: {last}, {now}")
last = now
except StopIteration:
print(ans) |
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==1:
if a[j] <= a[j+1]:
continue
else:
ans+=1
check=plus_minus(j+1)
else:
if a[j]>=a[j+1]:
continue
else:
ans+=1
check=plus_minus(j+1)
print(ans) |
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 check==1:
if a[j] <= a[j+1]:
continue
else:
ans+=1
check=plus_minus(j+1)
else:
if a[j]>=a[j+1]:
continue
else:
ans+=1
check=plus_minus(j+1)
print(ans) |
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:
if a[j] <= a[j+1]:
continue
else:
ans+=1
check=plus_minus(j+1)
else:
if a[j]>=a[j+1]:
continue
else:
ans+=1
check=plus_minus(j+1)
print(ans) |
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.