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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s500936331 | p03741 | u663710122 | 1544736156 | Python | Python (3.4.3) | py | Runtime Error | 105 | 14332 | 365 | N = int(input())
A = list(map(int, input().split()))
def solve(i, s, k, sign):
if i == N:
return k
if sign * (s + A[i]) > 0:
return solve(i + 1, s + A[i], k, sign * -1)
else:
return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1)
try:
print(min(solve(0, 0, 0, 1), solve(... |
s573159381 | p03741 | u663710122 | 1544736117 | Python | Python (3.4.3) | py | Runtime Error | 103 | 14332 | 366 | N = int(input())
A = list(map(int, input().split()))
def solve(i, s, k, sign):
if i == N:
return k
if sign * (s + A[i]) > 0:
return solve(i + 1, s + A[i], k, sign * -1)
else:
return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1)
try:
print(min(solve(0, 0, 0, 1), solve(... |
s979534737 | p03741 | u663710122 | 1544736033 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14212 | 366 | N = int(input())
A = list(map(int, input().split()))
def solve(i, s, k, sign):
if i == N:
return k
if sign * (s + A[i]) > 0:
return solve(i + 1, s + A[i], k, sign * -1)
else:
return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1)
try:
print(min(solve(0, 0, 0, 1), solve(... |
s741682015 | p03741 | u663710122 | 1544735786 | Python | Python (3.4.3) | py | Runtime Error | 105 | 14332 | 327 | N = int(input())
A = list(map(int, input().split()))
def solve(i, s, k, sign):
if i == N:
return k
if sign * (s + A[i]) >= 0:
return solve(i + 1, s + A[i], k, sign * -1)
else:
return solve(i + 1, sign, k + abs(s + A[i]) + 1, sign * -1)
print(min(solve(0, 0, 0, 1), solve(0, 0, 0,... |
s059170332 | p03741 | u663710122 | 1544735040 | Python | PyPy3 (2.4.0) | py | Runtime Error | 446 | 71508 | 508 | N = int(input())
A = list(map(int, input().split()))
def solve(i, s, k, plus):
if i == N:
return k
if plus:
if s + A[i] <= 0:
return solve(i + 1, 1, k + abs(s + A[i]) + 1, False)
else:
return solve(i + 1, s + A[i], k, False)
else:
if s + A[i] >= 0:
... |
s707716351 | p03741 | u663710122 | 1544734634 | Python | Python (3.4.3) | py | Runtime Error | 108 | 14468 | 508 | N = int(input())
A = list(map(int, input().split()))
def solve(i, s, k, plus):
if i == N:
return k
if plus:
if s + A[i] <= 0:
return solve(i + 1, 1, k + abs(s + A[i]) + 1, False)
else:
return solve(i + 1, s + A[i], k, False)
else:
if s + A[i] >= 0:
... |
s445160207 | p03741 | u236127431 | 1543726423 | Python | PyPy3 (2.4.0) | py | Runtime Error | 172 | 38384 | 84 | X,Y=map(int,input().split())
if abs(X-Y)<=1:
print("Brown")
else:
print("Alice") |
s401089883 | p03741 | u667024514 | 1537579438 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 406 | n = int(input())
lis = list(map(int,input().split()))
cou = 0
co = 0
ans1 = 0
ans2 = 0
for i in range(n):
cou += lis[i]
co += lis[i]
if cou <= 0 and i % 2 == 0:
ans1 += (1 -cou)
cou = 1
if cou => 0 and i % 2 == 1:
ans1 += (cou +1)
cou = -1
if co => 0 and i % 2 == 0:
ans2 += (co +1)
co ... |
s260247229 | p03741 | u808427016 | 1534564520 | Python | Python (3.4.3) | py | Runtime Error | 121 | 14468 | 370 | N = int(input())
A = [int(_) for _ in input().split()]
def calc(A, y):
result = abs(A[0] - y)
t = y
for a in A[1:N]:
tt = t + a
if t * tt >= 0:
m = -t // abs(t)
result += abs(m - tt)
tt = m
t = tt
return result
result = min(calc(A, A[0]), ca... |
s350153079 | p03741 | u149260203 | 1526393353 | Python | Python (3.4.3) | py | Runtime Error | 284 | 23316 | 700 | import numpy as np
def dp(i,n):
if i == 0:
if a[0] == 0:
if n == 1:
return 1,1
elif np.sign(a[1]) != 0:
return -1 * np.sign(a[1]), 1
else:
return 1,1
else:
return a[0],0
else:
sg,count = dp(... |
s983402195 | p03741 | u149260203 | 1526392416 | Python | Python (3.4.3) | py | Runtime Error | 301 | 23324 | 683 | import numpy as np
def dp(i,n):
if i == 0:
if a[0] == 0:
if n == 1:
return 1,1
elif np.sign(a[1]) != 0:
return -1 * np.sign(a[1]), 1
else:
return 1,1
else:
return a[0],0
else:
sg,count = dp(... |
s739361856 | p03741 | u149260203 | 1526391693 | Python | Python (3.4.3) | py | Runtime Error | 320 | 23284 | 612 | import numpy as np
def dp(i):
if i == 0:
if a[0] == 0:
if n == 1:
return 1,1
else:
return -1 * np.sign(a[1]), 1
else:
return a[0],0
else:
sg,count = dp(i-1)
if np.sign(sg) == -1 * np.sign(sg+a[i]):
... |
s891760011 | p03741 | u520158330 | 1525986315 | Python | Python (3.4.3) | py | Runtime Error | 165 | 14468 | 521 | N = int(input())
A = list(map(int,input().split()))
B = [A[0],(-1)*(A[0])//abs(A[0])]
ANS = []
#print(b)
for i in range(len(B)):
b = B[i]
ans = 0
if i==1: ans = abs(b)+1
for a in A[1:]:
#print("a+b"+str(a+b))
if a+b==0:
ans += 1
b = (-1)*(b)//abs(b)
eli... |
s888392224 | p03741 | u257974487 | 1517942373 | Python | Python (3.4.3) | py | Runtime Error | 119 | 14468 | 645 | n = int(input())
numbers = list(map(int,input().split()))
p = numbers[0]
a, b = 0, 0
if p > 0:
q = -1
b = p + 1
elif p < 0:
q = 1
b = -p + 1
for i in range(1, n):
if p > 0:
p += numbers[i]
if p >= 0:
a += (p + 1)
p -= (p + 1)
else:
p += number... |
s681358123 | p03741 | u249381466 | 1493779289 | Python | Python (3.4.3) | py | Runtime Error | 114 | 14332 | 226 | n = int(input())
a = list(map(int, input().split()))
s = a[0]
ans = 0
for i in range(1, n):
ans += abs(s + a[i]) + 1 if s * (s + a[i]) >= 0 else 0
s = -1 * s // abs(s) if s * (s + a[i]) >= 0 else s + a[i]
print(ans)
|
s906316512 | p03741 | u682181971 | 1493527129 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38640 | 193 | N,T =map(int,input().split())
t = map(int,input().split())
amount =0
for index in range(N-1):
t_sub = t[index+1]-t[index]
amount+=min(t_sub,T)
amount +=T
print(amount) |
s549572262 | p03741 | u138241646 | 1492913587 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3056 | 68 | import sys,time
X, Y = map(int,input().split())
time.sleep((X%7)/5)
|
s645926008 | p03741 | u049297964 | 1492912334 | Python | Python (3.4.3) | py | Runtime Error | 307 | 23284 | 973 | import numpy as np
import math
n = int(input())
a = list(map(int,input().split()))
maenogoukei = a[0]
goukei = a[0]
kaisuu = 0
if goukei == 0:
kaisuu += 1
maenogoukei = -1
goukei = maenogoukei
for a_i in a[1:]:
goukei += a_i
if maenogoukei > 0 and goukei >= 0:
kaisuu += goukei + 1
goukei = -1
maenogou... |
s235916388 | p03741 | u209551477 | 1492909798 | Python | PyPy3 (2.4.0) | py | Runtime Error | 263 | 63984 | 229 | N = int( input() )
A = list( map( int, input().split() ) )
ans = 0
s = A[ 0 ]
for i in range( 1, N, 1 ):
ns = s + A[ i ]
if ns * s >= 0:
ns = s // abs( s ) * -1
ans += abs( ns - ( s + A[ i ] ) )
s = ns
print( ans )
|
s741238051 | p03742 | u623349537 | 1560725096 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 96 | A, B = map(int, input().split())
if abs(A - b) <= 1:
print("Brown")
else:
print("Alice") |
s026489267 | p03742 | u013750540 | 1522362705 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 107 | x,y = map(int,input().split())
if x>y:
swap(x,y)
if y-x>1:
print("Alice")
else:
print("Brown") |
s628511411 | p03742 | u013750540 | 1522362654 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 107 | x,y = map(int,input().split())
if x>y:
swap(x,y)
if y-x>1:
print("Alice")
elif:
print("Brown") |
s199756163 | p03742 | u013750540 | 1522362595 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 107 | x,y = map(int,input().split())
if x>y:
swap(x.y)
if y-x>1:
print("Alice")
elif:
print("Brown") |
s424331511 | p03742 | u528224561 | 1517452022 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 137 | if __name__='__main__':
m,n = map(int,input().split())
if abs(m-n)>1:
print('Alice')
else:
print('Brown')
|
s048890548 | p03742 | u407593401 | 1492995304 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 387 | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
int main()
{
//freopen("input.in", "r", stdin);
ll n, m;
while(scanf("%lld%lld", &n, &m)!=EOF){
if(abs(n-m)<2)
printf... |
s055558351 | p03742 | u407593401 | 1492995014 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 133 | X, Y = map( int, input().split() )
if X > Y:
X, Y = Y, X
if X == Y or X + 1 == Y:
print( "Brown" )
else:
print( "Alice" ) |
s353928983 | p03742 | u673344713 | 1492964643 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 86 | x,y=map(int,raw_input().split())
if abs(x,y)<=1:
print "Brown"
else:
print "Alice"
|
s625684125 | p03742 | u049297964 | 1492913733 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 441 | X,Y = list(map(int,input().split()))
def game(x,y,turn="Alice"):
if x <= 1 and y <= 1:
if turn == "Alice":
return "Brown"
else:
return "Alice"
return "Alice"
elif x >= y:
if turn == "Alice":
return game(x%2, y+(x-x%2)/2, "Brown")
else:
return game(x%2, y+(x-x%2)/2, "Alice")
else:
if turn =... |
s484549724 | p03742 | u138241646 | 1492913360 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 55 | import sys
X, Y = map(int,input().split())
sys.exit(X)
|
s316553352 | p03743 | u737214831 | 1556657655 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1305 | #include <bits/stdc++.h>
#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a... |
s198745283 | p03743 | u327466606 | 1497338491 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 230 | x = 1
for i,d in zip(reversed(range(len(D))), reversed(D)):
if Q[-1][0] == i:
result[Q[-1][1]] = P[i] >= x
Q.pop()
if not Q:
break
if abs(x-d) < x:
x += d
for r in result:
print('YES' if r else 'NO') |
s677060395 | p03743 | u532827876 | 1497217278 | Python | Python (3.4.3) | py | Runtime Error | 114 | 77988 | 843 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
N,D = map(int, sys.stdin.readline().rstrip().split())
ds = map(int, sys.stdin.readline().rstrip().split())
Q, = map(int, sys.stdin.readline().rstrip().split())
qs = map(int, sys.stdin.readline().rstrip().split())
qs.sort()
targets = [1]
for d in revers... |
s236591111 | p03744 | u104282757 | 1493082820 | Python | Python (3.4.3) | py | Runtime Error | 3167 | 106236 | 1216 | # F
import numpy as np
from collections import deque
TT_list = []
# input
N, L = map(int, input().split())
T = 0.0
vt_now = 0.0
v_now = 0
que = deque()
for i in range(N):
ti, v = map(int, input().split())
t = float(ti)
v_now += v
vt_now += v*t
# add
if v == L:
que.append([t, v])
e... |
s600392546 | p03744 | u104282757 | 1493081708 | Python | Python (3.4.3) | py | Runtime Error | 148 | 12504 | 1374 | # F
import numpy as np
from collections import deque
TT_list = []
# input
N, L = map(int, input().split())
T = 0.0
vt_now = 0.0
v_now = 0
que = deque()
for i in range(N):
ti, v = map(int, input().split())
t = float(ti)
v_now += v
vt_now += v*t
# add
if v == L:
que.deque([t, v])
el... |
s934100916 | p03744 | u407593401 | 1493070375 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1464 | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <deque>
using namespace std;
typedef long long ll;
int main()
{
//freopen("input.in", "r", stdin);
ll N, L;
while(cin>>N>>L){
deque<pair<ll, ll>> dp;
vecto... |
s148275939 | p03744 | u854685751 | 1492936337 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2808 | 555 | from collections import deque
N, L = map(int,input().split())
q = deque()
t, v = map(int,input().split())
q.append((t,v))
res = ""
res += str(t) + "\n"
ene = t*v
for que in [map(int,input().split()) for _ in range(N-1)]:
t, v = que
rest = v
ene += t*v
while rest > 0:
t_, v_ = q.pop()
if v_ > rest:
q.append(... |
s701601153 | p03744 | u049297964 | 1492936008 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3316 | 1093 | from collections import deque
N,L = list(map(int,input().split()))
List = []
########################################
result = ""
t1,v1 = map(int,input().split())
d = deque( [(t1,v1)] )
netsuryou = t1*v1
res += str(t1) + "\n"
for t,v in [ map(int,input().split()) for _ in range(N-1) ]:
netsuryou += t*v
#右端か... |
s407891909 | p03744 | u692632484 | 1492914304 | Python | Python (3.4.3) | py | Runtime Error | 3156 | 3692 | 492 | temp=input().split()
N=int(temp[0])
L=int(temp[1])
t=[]
v=[]
throw=0#amount of throw water
index=0
for I in range(N):
temp=input().split()
t+=[int(temp[0])]
v+=[int(temp[1])]
if I==0:
print(t[0])
continue
throw=v[I]
while True:
coldTemp=min(t[:-1])
coldIndex=t.index(coldTemp)
if throw<v[coldIndex]:... |
s112200166 | p03745 | u394731058 | 1601137304 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 85392 | 249 | ans = 1
N = int(input())
A = list(map(int, input().split()))
up = True
if A[0] > A[1]:
up = False
for i in range(1, N-1):
if A[i] > A[i+1] and up:
ans += 1
up = False
elif A[i] < A[i+1] and not up:
ans += 1
up = True
print(ans) |
s696884538 | p03745 | u148981246 | 1600917378 | Python | Python (3.8.2) | py | Runtime Error | 91 | 20132 | 472 | n = int(input())
a = list(map(int, input().split()))
d = [x1 - x0 for x1, x0 in zip(a[1:], a) if x1 - x0 != 0]
def sign(x):
if x > 0:
return 1
elif x < 0:
return -1
else:
return 0
cnt = 0
prev = d[0]
kept = 1
for i in range(1, len(d)):
if sign(d[i]) == prev:
kept = 1
... |
s774188418 | p03745 | u626337957 | 1600899716 | Python | PyPy3 (7.3.0) | py | Runtime Error | 104 | 74232 | 328 | N = int(input())
nums = list(map(iunt, input().split()))
upper = True
lower = True
before = nums[0]
answer = 0
for i, num in enumerate(nums):
if before < num:
lower = False
elif before > num:
upper = False
before = num
if not upper and not lower:
answer += 1
upper = True
lower = True
print(a... |
s687520053 | p03745 | u348293370 | 1600701603 | Python | Python (3.8.2) | py | Runtime Error | 95 | 20328 | 481 | n = int(input())
num_list = list(map(int, input().split()))
ans = 1
cnt_list = [0] * n
for i in range(1,n):
if num_list[i-1] > num_list[i]:
cnt_list[i] = -1
if num_list[i-1] < num_list[i]:
cnt_list[i] = 1
for i in range(1,n-1):
if cnt_list[i] == -1 * cnt_list[1]:
if cnt_list[i+1] =... |
s822953367 | p03745 | u306412379 | 1600363633 | Python | Python (3.8.2) | py | Runtime Error | 98 | 20124 | 325 | n = int(input())
aa =list(map(int, input().split()))
list1 =[0] * n
list1[0] = 1
list1[1] = 1
for i in range(2,n):
if list1[i-2] == list1[i-1]:
if (aa[i] - aa[i-1]) * (aa[i-1] -aa[i-2]) < 0:
list1[i] = list1[i-1] + 1
else:
list1[i] = list1[i-1]
else:
list1[i] = list1[i-1]
print(list1[... |
s681432292 | p03745 | u520276780 | 1600225174 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 87328 | 199 | #editorial
n=int(input())
*a,=map(int, input().split())
pre=a[1]-a[0]
ans=1
for i in range(2,n):
if pre*(a[i]-a[i-1])<0:
pre=0
ans+=1
else:
pre=a[i]-a[i-1]
print(ans)
|
s228631361 | p03745 | u999503965 | 1599705848 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9008 | 404 | n=int(input())
l=list(map(int,input().split()))
if n=<2:
print(1)
exit()
cnt=0
if l[0]>l[1]:
ans="low"
elif l[0]<l[1]:
ans="high"
else:
ans="even"
for i in range(2,n):
if l[i-1]>l[i] and (ans=="low" or ans=="even"):
ans="low"
elif l[i-1]<l[i] and (ans=="high" or ans=="even"):
ans="high"
... |
s011354557 | p03745 | u999503965 | 1599705130 | Python | Python (3.8.2) | py | Runtime Error | 84 | 20108 | 373 | n=int(input())
l=list(map(int,input().split()))
cnt=0
if l[0]>l[1]:
ans="low"
elif l[0]<l[1]:
ans="high"
else:
ans="even"
for i in range(2,n):
if l[i-1]>l[i] and (ans=="low" or ans=="even"):
ans="low"
elif l[i-1]<l[i] and (ans=="high" or ans=="even"):
ans="high"
elif l[i-1]==l[i]:
ans="even... |
s668242974 | p03745 | u583507988 | 1599407624 | Python | Python (3.8.2) | py | Runtime Error | 90 | 20324 | 297 | n=int(input())
a=list(map(int,input().split()))
ans=0
data=[0]*(n-1)
for i in range(n-1):
data[i]=a[i+1]-a[i]
for i in range(1,n-2):
if data[i]<0:
if data[i-1]>0 or data[i+1]>0:
ans+=1
if data[0]<0:
if data[1]>0:
ans+=1
if data[n-2]<0:
if data[n-3]>0:
ans+=1
print(ans+1) |
s782223094 | p03745 | u942051624 | 1599343721 | Python | Python (3.8.2) | py | Runtime Error | 79 | 20136 | 243 |
N=int(input())
A=list(map(int,input().split()))
B=[A[i]-A[i-1] for i in range(1,N)]
ans=0
first=B[0]
for i in range(N-1):
if first*B[i]>=0:
pass
else:
ans+=1
if i+1<=N-2:
first=B[i+1]
print(ans+1) |
s893056127 | p03745 | u819135704 | 1599239627 | Python | Python (3.8.2) | py | Runtime Error | 96 | 20388 | 499 | N = int(input())
A = list(map(int, input().split()))
a=A[0]; c=1; i=1; w=0
def f(x):
return A[x], x+1
while True:
if w==0:
if A[i]==a:
a,i=f(i)
elif A[i] > a:
w=1; a,i=f(i)
else:
w=-1; f(i)
elif w>0:
if A[i]>=a:
a,i=f(i)
... |
s513915495 | p03745 | u819135704 | 1599239569 | Python | Python (3.8.2) | py | Runtime Error | 78 | 20208 | 498 | N = int(input())
A = list(map(int, input().split()))
a=A[0]; c=1; i=1; w=0
def f(x):
return A[x], x+1
while True:
if w==0:
if A[i]==a:
a,i=f(i)
elif A[i] > a:
w=1; a,i=f(i)
else:
w=-1; f(i)
elif w>0:
if A[i]>=a:
a,i=f(i)
... |
s700761588 | p03745 | u464205401 | 1598918119 | Python | Python (3.8.2) | py | Runtime Error | 1335 | 146752 | 356 | from collections import deque
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
tmp = []
cnt = 0
while d:
v = d.popleft()
tmp.append(v)
if len(tmp)<=2:
pass
else:
if not ( tmp[-1] >= tmp[-2] >= tmp[-3] or tmp[-1] <= tmp[-2] <= tmp[-3]):
tmp = [tmp[-1]]
cnt += 1
print(d,... |
s158624427 | p03745 | u464205401 | 1598877088 | Python | Python (3.8.2) | py | Runtime Error | 78 | 20416 | 412 | n = int(input())
a = list(map(int,input().split()))
flg = "default" #increase_flg
cnt = 0
for i in range(n-1):
if a[i+1] > a[i]:
if not flg:
cnt+=1
flg = "default"
else:
flg = True
elif a[i+1] < a[i]:
if flg:
cnt+=1
flg = "default"
else:
flg = False
# print(a[i]... |
s782143454 | p03745 | u536017058 | 1598683353 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 84832 | 417 | n = int(input())
a = list(map(int, input().split()))
ans = 1; togU = 0; togD = 0
if a[1]>a[0]: togU = 1
elif a[1]<a[0]: togD = 1
for i in range(1,n):
if not (togD or togU):
if a[i]>a[i-1]: togU = 1; continue
if a[i]<a[i-1]: togD = 1; continue
if a[i]>a[i-1]:
if togD:
ans += 1
togD = 0
... |
s068562184 | p03745 | u263824932 | 1597991999 | Python | PyPy3 (7.3.0) | py | Runtime Error | 288 | 84248 | 502 | N=int(input())
A=list(map(int,input().split()))
flag=0
answer=1
if A[0]<A[1]:
flag=1
else:
flag=-1
for n in range(N-1):
if flag==1:
if A[n]<=A[n+1]:
pass
else:
flag=0
answer+=1
elif flag==-1:
if A[n]>=A[n+1]:
pass
else:
... |
s209995511 | p03745 | u168416324 | 1597857387 | Python | Python (3.8.2) | py | Runtime Error | 71 | 20024 | 206 | n=int(input())
lis=list(map(int,input().split()))
ans=1
bb=lis.pop(0)
b=lis.pop(0)
f=False
for i in lis:
if f:
f^=1
elif (bb>b and b<i) or (bb<b and b>i):
ans+=1
f^=1
bb=b
b=i
print(ans) |
s725978832 | p03745 | u168416324 | 1597857233 | Python | Python (3.8.2) | py | Runtime Error | 67 | 19984 | 170 | n=int(input())
lis=list(map(int,input().split()))
ans=1
bb=lis.pop(0)
b=lis.pop(0)
for i in lis:
if (bb>b and b<i) or (bb<b and b>i):
ans+=1
bb=b
b=i
print(ans) |
s633106503 | p03745 | u191423660 | 1597366033 | Python | Python (3.8.2) | py | Runtime Error | 48 | 20344 | 504 | def solve():
N = int(input())
A = list(map(int, input().split()))
i = 0
result = 0
while i < N:
while i+1 < n and A[i] == A[i+1]:
i += 1
if i+1 < N and A[i] < A[i+1]:
while i+1 < n and A[i] <= A[i+1]:
i += 1
elif i+1 < N and A[i] > ... |
s285558888 | p03745 | u191423660 | 1597365892 | Python | Python (3.8.2) | py | Runtime Error | 48 | 20288 | 504 | def solve():
N = int(input())
A = list(map(int, input().split()))
i = 0
result = 0
while i < n:
while i+1 < n and A[i] == A[i+1]:
i += 1
if i+1 < n and A[i] < A[i+1]:
while i+1 < n and A[i] <= A[i+1]:
i += 1
elif i+1 < n and A[i] > ... |
s743080403 | p03745 | u075303794 | 1597161298 | Python | Python (3.8.2) | py | Runtime Error | 83 | 20952 | 779 | N=int(input())
A=list(map(int,input().split()))
div_flg=False
inc_flg=False
dec_flg=False
ans=0
for i in range(N):
if inc_flg:
if i==N-1:
break
if A[i]<=A[i+1]:
continue
else:
inc_flg=False
div_flg=False
elif dec_flg:
if i==N-1:
break
if A[i]>=A[i+1]:
continu... |
s496501014 | p03745 | u075303794 | 1597161105 | Python | Python (3.8.2) | py | Runtime Error | 85 | 20064 | 731 | N=int(input())
A=list(map(int,input().split()))
div_flg=False
inc_flg=False
dec_flg=False
ans=0
for i in range(N):
if inc_flg:
if i==N-1:
break
if A[i]<=A[i+1]:
continue
else:
inc_flg=False
div_flg=False
elif dec_flg:
if i==N-1:
break
if A[i]>=A[i+1]:
continu... |
s346097384 | p03745 | u444238096 | 1597071813 | Python | Python (3.8.2) | py | Runtime Error | 393 | 20280 | 421 | N = int(input())
A = list(map(int, input().split()))
for i in range(N-2):
if A[i]==A[i+1]:
del A[i+1]
for i in range(len(A)-1):
if A[i]<A[i+1]:
A[i]="a"
elif A[i]>A[i+1]:
A[i]="b"
ans1=1
ans2=1
for i in range(len(A)-1):
if A[i]=="a" and A[i+1]=="b":
ans1=ans1+1
elif... |
s537912932 | p03745 | u637289184 | 1596921939 | Python | PyPy3 (7.3.0) | py | Runtime Error | 107 | 87040 | 744 | N = int(input())
A = list(map(int, input().split()))
B=[2]*(N)
if n<=2:
print(1)
exit(0)
for i in range(N-1):
if A[i]>A[i+1]:
B[i]=-1
elif A[i]==A[i+1]:
B[i]=0
elif A[i]<A[i+1]:
B[i]=1
i=0
cnt=[0]*N
while True:
if B[i]==1:
if B[i+1]==0 or B[i+1]==1:
... |
s590854501 | p03745 | u212502386 | 1596851652 | Python | Python (3.8.2) | py | Runtime Error | 84 | 20040 | 254 | N=int(input())
A=list(map(int,input().split()))
turn=A[1]-A[0]
ans=1
if N>2:
for i in range(1,N-1):
judge=turn * (A[i+1]-A[i])
if judge<0:
ans+=1
turn=0
else:
turn=A[i+1]-A[i]
print(ans) |
s469121708 | p03745 | u212502386 | 1596851511 | Python | Python (3.8.2) | py | Runtime Error | 84 | 19896 | 217 | N=int(input())
A=list(map(int,input().split()))
turn=A[1]-A[0]
ans=1
for i in range(1,N-1):
judge=turn * (A[i+1]-A[i])
if judge<0:
ans+=1
turn=0
else:
turn=A[i+1]-A[i]
print(ans) |
s309676754 | p03745 | u876742094 | 1596234184 | Python | PyPy3 (7.3.0) | py | Runtime Error | 173 | 74176 | 336 | N=int(input())
A=list(map(int,input().split()))
counter=1
while len(A)>1:
if A[0]=A[1]:
A=A[1:]
else:
res=(A[1]>A[0])
for i in range(len(A)-1):
if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
A=A[i+1:]
counter+=1
break
... |
s695141733 | p03745 | u876742094 | 1596233782 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 236036 | 266 | N=int(input())
A=list(map(int,input().split()))
counter=1
while len(A)>1:
res=(A[1]>=A[0])
for i in range(len(A)):
if (A[i+1]<A[i] and res) or (A[i+1]>A[i] and not res):
A=A[i+1:]
counter+=1
break
print(counter)
|
s498600376 | p03745 | u876742094 | 1596233188 | Python | PyPy3 (7.3.0) | py | Runtime Error | 97 | 85324 | 306 | N=int(input())
A=list(map(int,input().split()))
counter=1
res=(A[1]>=A[0])
if N==1:
print(1)
else:
for i in range(N-1):
if A[i+1]<A[i] and res:
res=False
counter+=1
elif A[i+1]>A[i] and not res:
res=True
counter+=1
print(counter)
|
s525556515 | p03745 | u370721525 | 1596193019 | Python | Python (3.8.2) | py | Runtime Error | 75 | 20316 | 760 | N = int(input())
A = list(map(int, input().split()))
ans = 0
def main(i, A):
global N
global ans
if A[i] == A[i+1]:
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
elif A[i] < A[i+1]:
while i < N-1:
if A[i] <= A[i+1]:
i += 1
else:
ans += 1
... |
s439482709 | p03745 | u370721525 | 1596192618 | Python | Python (3.8.2) | py | Runtime Error | 73 | 20428 | 730 | N = int(input())
A = list(map(int, input().split()))
ans = 0
def main(i, A):
global N
global ans
if A[i] == A[i+1]:
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
elif A[i] < A[i+1]:
while i < N-1:
if A[i] <= A[i+1]:
i += 1
else:
ans += 1
... |
s142812261 | p03745 | u370721525 | 1596192516 | Python | Python (3.8.2) | py | Runtime Error | 75 | 20528 | 669 | N = int(input())
A = list(map(int, input().split()))
ans = 0
def main(i, A):
global N
global ans
if A[i] == A[i+1]:
return main(i+1, A)
elif A[i] < A[i+1]:
while i < N-1:
if A[i] <= A[i+1]:
i += 1
else:
ans += 1
if i == N-2:
ans += 1
return ans
... |
s470696243 | p03745 | u562015767 | 1595711571 | Python | PyPy3 (7.3.0) | py | Runtime Error | 107 | 84908 | 423 | n = int(input())
a = list(map(int,input().split()))
f = 0
cnt = 0
if a[0] < a[1]:
f = 1
elif a[0] > a[1]:
f = 2
tmp = a[1]
for i in range(2,n):
if tmp < a[i]:
if f == 2:
cnt += 1
f = 0
elif f == 0:
f = 1
elif tmp > a[i]:
if f == 1:
... |
s163469255 | p03745 | u562015767 | 1595711538 | Python | PyPy3 (7.3.0) | py | Runtime Error | 99 | 84896 | 450 | n = int(input())
a = list(map(int,input().split()))
f = 0
cnt = 0
if a[0] < a[1]:
f = 1
elif a[0] > a[1]:
f = 2
tmp = a[1]
for i in range(2,n):
if tmp < a[i]:
if f == 2:
cnt += 1
f = 0
elif f == 0:
f = 1
elif tmp > a[i]:
if f == 1:
... |
s082959349 | p03745 | u548525760 | 1595336357 | Python | Python (3.8.2) | py | Runtime Error | 76 | 19988 | 543 | N = int(input())
A = list(map(int, input().split()))
ans = 1
if A[0] < A[1]:
status = "plus"
elif A[0] > A[1]:
status = "minus"
else:
status = "even"
for n in range(1, N):
if status == "even":
if A[n] == A[n-1]:
pass
elif A[n] > A[n-1]:
status = "plus"
else:
status = "minus"
e... |
s167811623 | p03745 | u730769327 | 1595100104 | Python | Python (3.8.2) | py | Runtime Error | 87 | 20296 | 312 | n=int(input())
a=list(map(int,input().split()))
ans=1
if a[0]<a[1]:flag=1
elif a[0]>a[1]:flag=-1
else:flag=0
for i in range(1,n-1):
if flag==1 and a[i]>a[i+1]:
ans+=1
flag=0
elif flag==-1 and a[i]<a[i+1]:
ans+=1
flag=0
else:
if a[i]>a[i+1]:flag=-1
elif a[i]<a[i+1]:flag=1
print(ans) |
s693923012 | p03745 | u088863512 | 1594684203 | Python | Python (3.8.2) | py | Runtime Error | 76 | 20420 | 818 | # -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
de... |
s936951196 | p03745 | u626891113 | 1594656438 | Python | PyPy3 (7.3.0) | py | Runtime Error | 103 | 84192 | 646 | n = int(input())
A = list(map(int, input().split()))
i = 1
ans = 1
plus = False
minus = False
while True:
while A[i] - A[i-1] == 0:
i += 1
if A[i] - A[i - 1] > 0:
plus = True
else:
minus = True
if plus:
while A[i] - A[i - 1] >= 0:
i += 1
if i == n... |
s545497800 | p03745 | u941438707 | 1594240759 | Python | Python (3.8.2) | py | Runtime Error | 117 | 20028 | 369 | n,*a=map(int,open(0).read().split())
b=0
if a[0]>a[1]:
b=-1
elif a[0]==a[1]:
b=0
else:b=1
c=[[a[0]]]
for i in range(1,n):
if (a[i]-a[i-1])*b>0:
c[-1]+=[a[i]]
else:
if len(c[-1])==1 or b==0:
c[-1]+=[a[i]]
else:c+=[[a[i]]]
if a[i-1]>a[i]:
b=-1
elif a[i... |
s222846080 | p03745 | u350093546 | 1593653353 | Python | Python (3.8.2) | py | Runtime Error | 95 | 20136 | 204 | n=int(input())
a=list(map(int,input().split()))
s=''
ans=1
for i in range(n-1):
if a[i]<a[i+1]:
s+='x'
elif a[i]>a[i+1]:
s+='y'
for i in range(len(s)):
if s[i]!=s[i+1]:
ans+=1
print(ans) |
s269304935 | p03745 | u084411645 | 1593595979 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8980 | 185 | p = -1
xp = -1
ans = 0
input()
for i in range(input().split(" ")):
i = int(i)
if i == p: continue
if p != -1:
x = p < i
if xp != -1
ans += x != xp
xp = x
p = i |
s241866425 | p03745 | u784022244 | 1593487849 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 74912 | 779 | A=list(map(int, input().split()))
if N<=2:
print(1)
exit()
now=0
ans=1
for i in range(1,N):
if i==1:
if A[i]-A[i-1]==0:
now=0
else:
now=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
if now>=1:
plus=True
elif now==0:
plus=-1
else:
... |
s129624081 | p03745 | u740284863 | 1593361777 | Python | Python (3.8.2) | py | Runtime Error | 92 | 19988 | 324 | n = int(input())
a = list(map(int,input().split()))
if a[-1] >= a[-2]:
a.append(float('inf'))
else:
a.append(-float('inf'))
ans = 1
i = 0
while i < n-1:
if a[i] < a[i+1] > a[i+2]:
ans += 1
i += 2
elif a[i] > a[i+1] < a[i+2]:
ans += 1
i += 2
else:
i += 1
print(... |
s939263265 | p03745 | u506858457 | 1593305928 | Python | Python (3.8.2) | py | Runtime Error | 99 | 20120 | 253 | N=int(input())
A=list(map(int,input().split()))
L=[]
ans=1
for i in range(N-1):
L.append(A[i+1]-A[i])
L.append(0)
#print(L)
L.remove(0)
#print(L)
M=len(L)
tmp=L[0]
for i in range(1,M):
if tmp*L[i]<0:
ans+=1
tmp*=-1
#print(tmp)
print(ans) |
s843140527 | p03745 | u802781234 | 1593229460 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9280 | 653 | n,l,t = map(int,input().split())
x = []
y = []
for i in range(n):
x.append(list(map(int,input().split())))
d = x[0][1]
b = x[0][0]
k = 2 * t
for i in range(1,n):
if(x[i][1] == d):
y.append(0)
else:
if d == 1:
sa = (x[i][0] - b)%l
else:
sa = (b - x[i][0])%l
... |
s350003433 | p03745 | u802781234 | 1593229364 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9276 | 653 | n,l,t = map(int,input().split())
x = []
y = []
for i in range(n):
x.append(list(map(int,input().split())))
d = x[0][1]
b = x[0][0]
k = 2 * t
for i in range(1,n):
if(x[i][1] == d):
y.append(0)
else:
if d == 1:
sa = (x[i][0] - b)%l
else:
sa = (b - x[i][0])%l
... |
s712966569 | p03745 | u000085263 | 1593204064 | Python | Python (3.8.2) | py | Runtime Error | 74 | 20076 | 569 | n = int(input())
l = list(map(int, input().split()))
x=[]
ans, count, q, xx = 0, 1, "<", 0
for i in range(n+1):
if q=='<':
if l[count]<=l[count-1]:
count+=1
continue
else:
if xx==0:
q=">"
xx+=1
continue
e... |
s516847398 | p03745 | u835283937 | 1592600128 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9096 | 1394 | def main():
# N = int(input())
# A = [int(a) for a in input().split()]
f = open("subtask_1_02.txt", "r")
N = int(f.readline())
A = [int(a) for a in f.readline().split()]
idx = 0
ans = 0
for i in range(len(A)):
if idx + 1 > len(A) - 1 :
break
m = ""
... |
s134312337 | p03745 | u253011685 | 1592426726 | Python | Python (3.4.3) | py | Runtime Error | 1898 | 140204 | 235 | N=int(input())
A=list(map(int,input().split()))
count=1
j=0
for i in range(N+1):
k=i
print(A[j:k])
if (A[j:k]==sorted(A[j:k]) or A[j:k]==sorted(A[j:k],reverse=True)):
continue
else:
count+=1
j=i-1
print(count) |
s468741714 | p03745 | u156815136 | 1592169643 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 1166 | #from statistics import median
import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import deque,defaultdict
#import bisect
#
# d = m - k[i]... |
s953694301 | p03745 | u106181248 | 1592021095 | Python | Python (3.4.3) | py | Runtime Error | 95 | 14224 | 530 | n = int(input())
li = list(map(int,input().split()))
x = 0 #まだ未定なら0、単調増加なら1、単調減少なら-1にする
i = 0 #index
ans = 0
while True:
if x == 0:
if li[i] < li[i+1]:
x = 1
elif li[i] > li[i+1]:
x = -1
else:
x = 0
if x == 1:
if li[i] > li[i+1]:
a... |
s979337024 | p03745 | u344122377 | 1591735166 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 540 | #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
#include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
signed main(){
int n; cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin >> a[i];
}
int ans = 0;
for(int i = 0; i < n; i++){
int right1 = ... |
s661956045 | p03745 | u810787773 | 1591584328 | Python | Python (3.4.3) | py | Runtime Error | 64 | 14480 | 1193 | def main():
N = int(input())
A = list(map(int, input().split()))
end = len(A)
judge = 0
ans = 0
i = 0
while True:
if A[i] < A[i+1]:
ans += 1
while True:
i += 1
if i == end-1:
return ans
elif ... |
s696522018 | p03745 | u076245995 | 1591543881 | Python | Python (3.4.3) | py | Runtime Error | 102 | 14224 | 347 | N = int(input())
A = list(map(int, input().split()))
count = 1
skip = False
for i in range(0, N-1):
if not skip:
before = A[i+1] - A[i]
after = A[i+2] - A[i+1]
if ((before > 0) - (before < 0))*((after > 0) - (after < 0)) == -1:
count += 1
skip = True
else:
... |
s719267170 | p03745 | u474925961 | 1591328491 | Python | Python (3.4.3) | py | Runtime Error | 183 | 23136 | 549 | import numpy as np
n=int(input())
a=list(map(int,input().split()))
#連続する重複を除外
arr=np.array(a)
diff=np.diff(arr,prepend=0)
aa=arr[np.nonzero(diff)]
#print(diff,aa)
aaa=aa.tolist()
point=[]
cnt=1
if len(aaa)<=2:
print(1)
else:
for i in range(len(aaa)-2):
if (aaa[i+1]-aaa[i])*(aaa[i+2]-aaa[i+1])<0:
... |
s396214312 | p03745 | u760636024 | 1591217672 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38256 | 462 | N = int(input())
A = list(map(int, input().split()))
status = 0 # 0 = defalt, 1 = up, 2 = down
cnt = 1
for i in range(1,N):
if A[i-1] < A[i]: #up petern
if status == 0 or status == 1:
status = 1
else:
status = 0
cnt += 1
elif A[i-1] > A[i]:
if status ... |
s275776895 | p03745 | u760636024 | 1591217611 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38384 | 481 | N = int(input())
A = list(map(int, input().split()))
status = 0 # 0 = defalt, 1 = up, 2 = down
cnt = 1
for i in range(1,N):
if A[i-1] < A[i]: #up petern
if status == 0 or status == 1:
status = 1
else status == 2:
status = 0
cnt += 1
elif A[i-1] > A[i]:
... |
s919502230 | p03745 | u017415492 | 1591212764 | Python | Python (3.4.3) | py | Runtime Error | 76 | 14224 | 647 | n=int(input())
a=list(map(int,input().split()))
increase_flag=False
decrease_flag=False
answer=0
for i in range(len(a)-1):
if increase_flag==False and decrease_flag==False:
if a[i+1]>a[i]:
increase_flag=True
answer+=1
elif a[i+1]<a[i]:
decrease_flag=True
answer+=1
else:
... |
s440677161 | p03745 | u954774382 | 1591115949 | Python | Python (3.4.3) | py | Runtime Error | 36 | 5124 | 1456 | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right a... |
s831779498 | p03745 | u075304271 | 1590682285 | Python | Python (3.4.3) | py | Runtime Error | 65 | 14252 | 311 | def solve():
n = int(input())
a = list(map(int, input().split()))
g, z = 0, 0
cut = 1
for i in range(n-1):
if a[i+1] > a[i]:
g += 1
elif a[i+1] < a[i]:
z += 1
if g != 0 and z != 0:
ans += 1
g, z = 0, 0
print(ans)
return 0
if __name__ == "__main__":
solve()
|
s380180799 | p03745 | u638902622 | 1590628167 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3444 | 845 | import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from enum import Enum, auto
#======================================================#
class State(Enum):
UP = auto()
DOWN = auto()
HORI = auto()
def main():
n = II... |
s901747583 | p03745 | u212328220 | 1590610409 | Python | Python (3.4.3) | py | Runtime Error | 94 | 14480 | 702 | n = int(input())
al = list(map(int, input().split()))
if al[1] > al[0]:
now = 'U'
elif al[1] < al[0]:
now = 'D'
else:
now = 'E'
cnt = 1
for i in range(2, n):
if now == 'U':
if al[i] > al[i-1] or al[i] == 'E':
now = 'U'
elif al[i] < al[i-1]:
cnt += 1
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.