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(0, 0, 0, -1)))
except TypeError:
print(1) |
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(0, 0, 0, -1)))
except ValueError:
print(1) |
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(0, 0, 0, -1)))
except IndexError:
print(1) |
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, -1)))
|
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:
return solve(i + 1, -1, k + abs(s + A[i]) + 1, True)
else:
return solve(i + 1, s + A[i], k, True)
print(min(solve(0, 0, 0, True), solve(0, 0, 0, False)))
|
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:
return solve(i + 1, -1, k + abs(s + A[i]) + 1, True)
else:
return solve(i + 1, s + A[i], k, True)
print(min(solve(0, 0, 0, True), solve(0, 0, 0, False)))
|
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 = -1
if co <= 0 and i % 2 == 1:
ans2 += (1 -co)
co = 1
print(min(ans1,ans2)) |
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]), calc(A, -A[1]-1), calc(A, -A[1]+1))
print(result)
|
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(i-1,n)
if np.sign(sg) == -1 * np.sign(sg+a[i]):
return sg+a[i], count
elif np.sign(sg) == 1:
delta = abs(-1 - (sg + a[i]))
return -1,count+delta
else:
delta = abs(1 - (sg + a[i]))
return 1,count+delta
n = int(input())
a = [int(i) for i in input().split()]
out_1,out_2 = dp(n-1,n)
print(out_2)
|
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(i-1,n)
if np.sign(sg) == -1 * np.sign(sg+a[i]):
return sg+a[i], count
elif np.sign(sg) == 1:
delta = abs(-1 - (sg + a[i]))
return -1,count+delta
else:
delta = abs(1 - (sg + a[i]))
return 1,count+delta
n = int(input())
a = [int(i) for i in input().split()]
print(dp(n-1,n)[1])
|
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]):
return sg+a[i], count
elif np.sign(sg) == 1:
delta = abs(-1 - (sg + a[i]))
return -1,count+delta
else:
delta = abs(1 - (sg + a[i]))
return 1,count+delta
n = int(input())
a = [int(i) for i in input().split()]
print(dp(n-1)[1]) |
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)
elif b*(a+b)<0:
b += a
else:
ans += abs(a+b)+1
#print("ans"+str(ans))
b = (-1)*(a+b)//abs(a+b)
#print(b)
ANS.append(ans)
print(min(ANS)) |
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 += numbers[i]
if p <= 0:
a -= (p - 1)
p -= (p - 1)
for j in range(1, n):
if q > 0:
q += numbers[j]
if q >= 0:
b += (q + 1)
q -= (q + 1)
else:
q += numbers[j]
if q <= 0:
b -= (q - 1)
q -= (q - 1)
print(min(a, b)) |
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
maenogoukei = -1
elif maenogoukei < 0 and goukei <= 0:
kaisuu += -goukei + 1
goukei = 1
maenogoukei = 1
else:
maenogoukei += a_i
maenogoukei2 = a[0]
goukei2 = a[0]
kaisuu2 = 0
if goukei2 == 0:
kaisuu2 += 1
maenogoukei2 = 1
goukei2 = 1
else:
kaisuu2 += math.abs(goukei2) + 1
maenogoukei2 = - int(np.sign(a[0]))
goukei2 = - int(np.sign(a[0]))
for a_i2 in a[1:]:
goukei2 += a_i2
if maenogoukei2 > 0 and goukei2 >= 0:
kaisuu2 += goukei2 + 1
goukei2 = -1
maenogoukei2 = -1
elif maenogoukei2 < 0 and goukei2 <= 0:
kaisuu2 += -goukei2 + 1
goukei2 = 1
maenogoukei2 = 1
else:
maenogoukei2 += a_i2
print( min([kaisuu,kaisuu2]) ) |
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("Brown\n");
else printf("Alice\n");
}
return 0;
}
|
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 == "Alice":
return game(x+(y-y%2)/2, y%2, "Brown")
else:
return game(x+(y-y%2)/2, y%2, "Alice")
print (game(X,Y)) |
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))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
inline int read() {
int x(0), sgn(1); char ch(getchar());
for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
return x * sgn;
}
void File() {
#ifdef zjp_shadow
freopen ("E.in", "r", stdin);
freopen ("E.out", "w", stdout);
#endif
}
const int N = 5e5 + 1e3;
int n, d[N], pre[N], f[N];
int main () {
File();
n = read(); pre[0] = read(); f[n + 1] = 1;
For (i, 1, n)
pre[i] = min(pre[i - 1], abs(pre[i - 1] - (d[i] = read())));
Fordown (i, n, 1)
f[i] = f[i + 1] + ((f[i + 1] << 1) > d[i] ? d[i] : 0);
For (i, 1, read()) {
int x = read();
puts(pre[x - 1] >= f[x + 1] ? "YES" : "NO");
}
return 0;
}
|
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 reversed(ds):
if(d//2 < targets[-1]):
targets.append(targets[-1] + d)
else:
targets.append(targets[-1])
targets.reverse()
current = D
can_avoids = []
for i in range(N):
d = ds[i]
target = targets[i+1]
#print("current:", current)
can_avoids.append(current >= target)
if d//2 < current:
current -= d
current = max(-current, current)
#print(targets)
#print(can_avoids)
for q in qs:
if (can_avoids[q-1]):
print("YES")
else:
print("NO")
exit(0)
|
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])
else:
while v < L and len(que) > 0:
t_, v_ = que.pop()
if t_ <= t:
que.append([t_, v_])
que.append([t, v])
break
elif v + v_ >= L:
v_ = v + v_ - L
t = ((L - v) * t_ + v * t) / L
v = L
que = deque([t, v])
v_now = L
vt_now = v*L
# break
else:
t = (t*v + t_*v_) / (v + v_)
v = v + v_
# minus
while v_now > L:
if que[0][1] <= v_now - L:
v_now -= que[0][1]
vt_now -= que[0][1]*que[0][0]
que.popleft()
else:
que[0][1] -= v_now - L
vt_now -= (v_now - L)*que[0][0]
v_now = L
TT_list.append(vt_now / L)
for i in range(N):
print(TT_list[i])
|
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])
else:
while v < L and len(que) > 0:
t_, v_ = que[-1]
if t_ <= t:
que.append([t, v])
break
elif v + v_ > L:
v_ = v + v_ - L
t = ((L - v) * t_ + v * t) / L
v = L
que = deque([[t, v]])
v_now = L
vt_now = t*L
# break
else:
t = (t*v + t_*v_) / (v + v_)
v = v + v_
if v == L:
que = deque([[t, v]])
v_now = L
vt_now = t*L
else:
que.pop()
# minus
while v_now > L:
if que[0][1] <= v_now - L:
v_now -= que[0][1]
vt_now -= que[0][1]*que[0][0]
que.popleft()
else:
que[0][1] -= v_now - L
vt_now -= (v_now - L)*que[0][0]
v_now = L
TT_list.append(vt_now / L)
for i in range(N):
print(TT_list[i])
|
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;
vector<ll> T(N, 0), V(N, 0);
for(int i=0;i<N;i++){
cin>>T[i]>>V[i];
}
ll tt=0, vv=0;
for(int i=0;i<N;i++){
ll t=T[i]*V[i], v=V[i];
while(vv+v>L){
ll t1=dp[0].first, v1=dp[0].second;
ll tmp=min(vv+v-L, v1);
tt=tt-t1*tmp/v1;
vv-=tmp;
if(tmp==v1){
dp.pop_front();
}
else{
dp[0].first=t1-t1*tmp/v1;
dp[0].second=v1-tmp;
}
}
tt+=t;
vv=L;
printf("%.7lf\n", (double)tt/vv);
int ans=dp.size();
ll c1=t;
ll c2=v;
while(ans){
ll t2=dp[ans-1].first, v2=dp[ans-1].second;
if(t2/v2<c1/c2){
break;
}
else{
c1+=t2;
c2+=v2;
dp.pop_back();
}
ans=dp.size();
}
dp.push_back(make_pair(c1, c2));
}
}
return 0;
}
|
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((t_, v_-rest))
ene -= rest*t_
break
else:
rest -= v_
ene -= v_*t_
while len(q) and t < q[0][0]:
t_, v_ = q.popleft()
t = (t*v+t_*v_)/(v+v_)
v = v+v_
q.appendleft((t,v))
res += str(ene/L) + "\n"
print(res)
|
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
#右端からvリットル減らす
l = v
while(l > 0):
migihasi_t,migihasi_v = d.pop()
if migihasi_v > l:
netsuryou -= migihasi_t*l
d.append( ( migihasi_t,migihasi_v-l ) )
break
else:
l = l - migihasi_v
netsuryou -= migihasi_t*migihasi_v
#答えを表示
res += str(netsuryou / L) + "\n"
#左のほうが温度が低ければ2つを合成
new_t,new_v = t,v
while(True):
if len(d) == 0:
d.appendleft( (new_t,new_v) )
break
hidarihasi_t,hidarihasi_v = d.popleft()
#条件を満たすならループを抜ける
if new_t >= hidarihasi_t:
d.appendleft( (hidarihasi_t,hidarihasi_v) )
d.appendleft( (new_t,new_v) )
break
new_v = new_v + hidarihasi_v
new_t = (new_t*new_v + hidarihasi_t*hidarihasi_v) / new_v
print (res)
|
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]:
v[coldIndex]-=throw
break
else:
throw-=v[coldIndex]
del v[coldIndex]
del t[coldIndex]
ans=0
for i in range(len(t)):
ans+=t[i]*v[i]
print(ans/L)
|
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
else:
if kept == 1:
cnt += 1
kept = 0
else:
kept = 1
prev = d[i]
else:
cnt += 1
print(cnt) |
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(answer+1) |
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] == cnt_list[1] or cnt_list[i-1] == cnt_list[1]:
ans+=1
if cnt_list[n-1] == -1 * cnt_list[1] and cnt_list[n-2] == cnt_list[1]:
ans += 1
print(ans) |
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[n-1]) |
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"
elif l[i-1]==l[i]:
continue
else:
cnt+=1
ans="even"
print(cnt+1)
|
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"
else:
cnt+=1
ans="even"
print(cnt+1) |
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)
else:
c+=1; a,i=f(i); w=0
elif w<0:
if A[i]<=a:
a,i=f(i)
else:
c+=1; a,i=f(i); w=0
if i==N:
break
print(c)
|
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)
else:
c+=1; a,i=f(i); w=0
elif w<0:
if A[i]<=a:
a,i=f(i)
else:
c+=1; a,i=f(); w=0
if i==N:
break
print(c)
|
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,tmp,cnt)
if tmp:
cnt+=1
print(cnt) |
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],a[i+1],flg,cnt)
if not a[i]>=a[i-1]>=a[i-2] or a[i]<=a[i-1]<=a[i-2]:
cnt +=1
print(cnt) |
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
togU = 0
elif a[i]<a[i-1]:
if togU:
ans += 1
togU = 0
togD = 0
print(ans) |
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:
flag=0
answer+=1
else:
if A[n]==A[n+1]:
pass
elif A[n]<A[n+1]:
flag=1
else:
flag=-1
print(answer)
|
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] > A[i+1]:
while i+1 < n and A[i] >= A[i+1]:
i += 1
result += 1
i += 1
print(result)
if __name__ == "__main__":
solve()
|
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] > A[i+1]:
while i+1 < n and A[i] >= A[i+1]:
i += 1
result += 1
i += 1
print(result)
if __name__ == "__main__":
solve()
|
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]:
continue
else:
dec_flg=False
div_flg=False
else:
if i==0:
ans+=1
div_flg=True
elif i==N-1:
if not div_flg:
ans+=1
break
if A[i]==A[i+1]:
if not div_flg:
ans+=1
div_flg=True
continue
elif A[i]<A[i+1]:
if not div_flg:
ans+=1
inc_flg=True
continue
elif A[i]>A[i+1]:
if not div_flg:
ans+=1
dec_flg=True
continue
print(ans) |
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]:
continue
else:
dec_flg=False
div_flg=False
else:
if i==0:
ans+=1
div_flg=True
elif i==N-1:
ans+=1
break
if A[i]==A[i+1]:
ans+=1
div_flg=True
continue
elif A[i]<A[i+1]:
if not div_flg:
ans+=1
inc_flg=True
continue
elif A[i]>A[i+1]:
if not div_flg:
ans+=1
dec_flg=True
continue
print(ans) |
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 A[i]=="b" and A[i+1]=="a":
ans2=ans2+1
if ans1==ans2:
ans1=ans1+1
print(max(ans1,ans2))
|
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:
i+=1
elif B[i+1]==-1:
if cnt[i-1]==0 or i==0:
cnt[i]=1
i+=1
else:
i+=1
if B[i]==0:
i+=1
if B[i]==-1:
if B[i+1]==0 or B[i+1]==-1:
i+=1
elif B[i+1]==1:
if cnt[i-1]==0 or i==0:
cnt[i]=1
i+=1
else:
i+=1
if B[i]==2:
break
print(cnt.count(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
print(counter)
|
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
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
else:
ans += 1
return ans
else:
while i < N-1:
if A[i] >= A[i+1]:
i += 1
else:
ans += 1
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
else:
ans += 1
return ans
if N == 1:
print(1)
else:
print(main(0, A)) |
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
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
else:
ans += 1
return ans
else:
while i < N-1:
if A[i] >= A[i+1]:
i += 1
else:
ans += 1
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
else:
ans += 1
return ans
print(main(0, A)) |
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
else:
return main(i+1, A)
else:
ans += 1
return ans
else:
while i < N-1:
if A[i] >= A[i+1]:
i += 1
else:
ans += 1
if i == N-2:
ans += 1
return ans
else:
return main(i+1, A)
else:
ans += 1
return ans
print(main(0, A)) |
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:
cnt += 1
f = 0
elif f == 0:
f = 2
tmp = a[i]
cnt += 1
print(cnt) |
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:
cnt += 1
f = 0
elif f == 0:
f = 2
else:
continue
tmp = a[i]
cnt += 1
print(cnt) |
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"
elif status == "plus":
if A[n] >= A[n-1]:
pass
else:
status = "minus"
ans += 1
elif status == "minus":
if A[n] <= A[n-1]:
pass
else:
status = "plus"
ans += 1
print(ans) |
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')
def solve():
n = int(input())
a = [int(x) for x in input().split()]
b = []
p = 0
for e in a:
if p != e:
b.append(e)
p = e
a = b
n = len(a)
p = -1
ans = 0
i = 1
while i < n:
if a[i-1] > a[i]:
x = 0
else:
x = 1
if p != x:
ans += x
p = x
i += 1
print(ans + (not x))
t = 1
# t = int(input())
for case in range(1,t+1):
ans = solve()
"""
"""
|
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:
break
else:
while A[i] - A[i -1] <= 0:
i += 1
if i == n:
break
if i == n:
break
if plus:
minus = True
plus = False
else:
plus = True
minus = False
ans += 1
if i != n -1:
i += 1
print(ans) |
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-1]==a[i]:
b=0
else:b=1
print(len(c)) |
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:
plus=False
else:
if A[i]-A[i-1]==0:
nex=0
else:
nex=(A[i]-A[i-1])//(abs(A[i]-A[i-1]))
if plus==-1:
if nex>=1:
plus=True
elif nex<0:
plus=False
elif plus:
if nex<0:
plus=-1
ans+=1
else:
if nex>0:
plus=-1
ans+=1
print(ans)
|
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(ans) |
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
if k >= sa:
y.append(1+int((k-sa)/l))
else:
y.append(0)
for i in range(n):
x[i][0] += t * pow(-1,x[i][1]+1)
x[i][0] %= l
sy = sum(y)
sx = sorted(x,key=lambda x:x[0])
if d==2:
sx = sx[-sy:] + sx[:-sy]
else:
sx = sx[sy:] + sx[:sy]
for i in range(n):
print(sx[i][0])
|
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
if k >= sa:
y.append(1+int((k-sa)/l))
else:
y.append(0)
for i in range(n):
x[i][0] += t * pow(-1,x[i][1]+1)
x[i][0] %= l
sy = sum(y)
sx = sorted(x,key=lambda x:x[0])
if d==2:
sx = sx[-sy:] + sx[:-sy]
else:
sx = sx[sy:] + sx[:sy]
for i in range(n):
print(sx[i][0])
|
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
else:
ans+=1
q=">"
continue
if q=='>':
if l[count]>=l[count-1]:
count+=1
continue
else:
ans+=1
q="<"
continue
print(ans+1) |
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 = ""
if A[idx] < A[idx + 1]:
m = "+"
elif A[idx] > A[idx + 1]:
m = "-"
else:
find = False
for j in range(idx, len(A)-1):
if A[j] < A[j + 1]:
m = "+"
find = True
idx = j
break
elif A[j] > A[j + 1]:
m = "-"
find = True
idx = j
break
if find == False:
print(ans + 1)
exit()
for j in range(idx, len(A) - 1):
if m == "+":
if A[j] <= A[j + 1]:
idx = j + 1
else:
idx = j + 1
ans += 1
break
elif m == "-":
if A[j] >= A[j + 1]:
idx = j + 1
else:
idx = j + 1
ans += 1
break
print(ans + 1)
if __name__ == "__main__":
main() |
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] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
return list(map(int,input().split()))
def I():
return int(input())
n = I()
S = readInts()
i = 0
cnt = 0
while i < n:
while i+1 < n:
if S[i] == S[i+1]:
i += 1
else:
break
if i + 1 < n:
if S[i] < S[i+1]:
while i + 1 < n:
if S[i] =< S[i+1]:
i += 1
else:
break
else:
while i + 1 < n:
if S[i] >= S[i+1]:
i += 1
else:
break
cnt += 1
i += 1
print(cnt)
|
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]:
ans += 1
x = 0
if x == -1:
if li[i] < li[i+1]:
ans += 1
x = 0
i += 1
if i == n-1:
break
print(ans+1) |
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 = i, right2 = i;
while(right1+1 < n && a[right1] <= a[right1+1]) right1++;
while(right2+1 < n && a[right2] >= a[right2+1]) right2++;
i = max(right1, right2);
ans++;
}
cout << ans << endl;
return 0;
} |
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 A[i] <= A[i+1]:
continue
else:
i += 1
if i == end-1:
ans += 1
return ans
else:
break
elif A[i] > A[i+1]:
ans += 1
while True:
i = i+1
if i == end-1:
return ans
elif A[i] >= A[i+1]:
continue
else:
i += 1
if i == end-1:
ans += 1
return ans
else:
break
elif A[i] == A[i+1]:
i += 1
if i == end-1:
ans += 1
return ans
else:
continue
print(main())
|
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:
skip = False
print(count)
|
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:
cnt+=1
point.append(i)
if len(point)>1:
for i in range(1,len(point)):
if point[i]-1==point[i-1]:
point[i]-=1
cnt-=1
print(cnt) |
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 == 0 or status == 2
status = 2
else:
status = 0
cnt += 1
else:
continue
print(cnt) |
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]:
if status == 0 or status == 2
status = 2
else status:
status = 0
cnt += 1
else:
continue
print(cnt) |
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:
if decrease_flag==True and a[i+1]>a[i]:
decrease_flag=False
elif increase_flag==True and a[i+1]<a[i]:
increase_flag=False
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
print(answer)
|
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 as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)
# def seive():
# prime=[1 for i in range(10**6+1)]
# prime[0]=0
# prime[1]=0
# for i in range(10**6+1):
# if(prime[i]):
# for j in range(2*i,10**6+1,i):
# prime[j]=0
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
if a[i-1]<a[i] and temp==0:
temp=1
elif a[i-1]>a[i] and temp==0:
temp=2
elif a[i-1]>a[i] and temp==1:
temp=0
ans=ans+1
elif a[i-1]<a[i] and temp==2:
temp=0
ans=ans+1
print(ans) |
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()
prev, *aa = MII()
state = State.HORI
cnt = 1
for a in aa:
if prev < a:
if state == State.HORI:
state = State.UP
elif state == State.DOWN:
cnt += 1
state = State.HORI
elif prev > a:
if state == State.HORI:
state = State.DOWN
elif state == State.UP:
cnt += 1
state = State.HORI
prev = a
print(cnt)
if __name__ == '__main__':
main() |
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
i += 1
now = 'E'
elif now == 'D':
if al[i] < al[i-1] or al[i] == 'E':
now = 'D'
elif al[i] > al[i-1]:
cnt += 1
now = 'E'
elif now == 'E':
if al[i] == al[i - 1]:
now = 'E'
elif al[i] > al[i - 1]:
now = 'U'
elif al[i] < al[i - 1]:
now = 'D'
print(cnt)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.