problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p03150 | s159310380 | Wrong Answer | s = input()
ans = 'NO'
pattern = 'keyence'
for i in range(len(pattern) - 1):
x = pattern[:i]
y = pattern[i:]
if s.find(x) >= 0:
if s.find(y, s.find(x) + len(x) - 1) >= 0:
ans = 'YES'
break
print(ans)
|
p03474 | s444206822 | Wrong Answer | a,b = map(int,input().split())
s = input()
lst = s.split("-")
#print(lst)
if len(lst[0]) == a and len(lst[1]) == b and len(lst) == 2:
print("Yes")
else:
print("no") |
p03997 | s955231320 | Accepted | a, b, h = [int(input()) for x in range(3)]
ans = (a + b) * h // 2
print(ans) |
p02835 | s362729027 | Wrong Answer | a, b, c = map(int, input().split())
if a + b + c <= 21:
print("win")
else:
print("burst") |
p03545 | s902398302 | Wrong Answer | *A, = list(input())
s = ['+', '-']
for i in range(2**3):
formula = A[0]
for j in range(3):
if i >> j & 1:
formula += s[0]
else:
formula += s[1]
formula += A[j+1]
if eval(formula) == 7:
print(formula)
exit() |
p02645 | s669225530 | Accepted | s=input()
print(s[0:3]) |
p03067 | s807651877 | Wrong Answer | a,b,c = map(int,input().split())
print("Yes" if a<=c<=b else "No")
|
p03086 | s249290527 | Accepted | S = input()
max_ctr = 0
ctr = 0
for i in range(len(S)):
if (S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G'):
ctr += 1
max_ctr = max(ctr, max_ctr)
else:
ctr = 0
print(max_ctr) |
p03665 | s533550098 | Wrong Answer | N,P = map(int, input().split())
A = list(map(int, input().split()))
in_odd = False
for i in range(N):
if A[i]%2:
in_odd = True
break
if not in_odd:
if P == 0:
print(0)
else:
print(2**(N-1)) |
p03067 | s448178902 | Accepted | a,b,c=map(int,input().split())
print("Yes"if a<=c<=b or b<=c<=a else "No") |
p02790 | s771534144 | Accepted | a,b=map(int,input().split())
astr=( str(a) * b )
bstr=( str(b) * a )
print(astr if astr < bstr else bstr) |
p02645 | s714983172 | Wrong Answer | name = input('')
print(name) |
p02775 | s756516543 | Accepted | N = [int(c) for c in input()][::-1]
N.append(0)
ans = 0
for i in range(len(N)):
c = N[i]
if c <= 4:
ans += c
elif 6 <= c:
ans += 10 - c
N[i + 1] += 1
else:
if N[i + 1] < 5:
ans += c
else:
ans += 10 - c
N[i + 1] += 1
print(ans) |
p02983 | s659140164 | Wrong Answer | l,r=map(int,input().split())
x=[]
if (r-l)>=2019:
print(0)
else:
for i in range(l,r+1):
x.append(i%2019)
x.sort()
print((x[0]*x[1])%2019) |
p02629 | s204320440 | Wrong Answer | n = int(input())
alphabet = [chr(i) for i in range(97, 123)]
ans = list()
for i in reversed(range(12)):
if x := n // (26 ** i):
ans.append(alphabet[x - 1])
n %= 26 ** i
print("".join(ans))
|
p04044 | s528820733 | Wrong Answer | s = [str(x) for x in input()]
s.sort()
s = "".join(s)
print(s) |
p02923 | s019893441 | Accepted | input()
a=c=t=0
for i in map(int,input().split()):
if i>t: c=0
else: c+=1; a=max(a,c)
t=i
print(a) |
p02775 | s875623522 | Accepted | s = list(input())
s.reverse()
s.append('0')
dp = [[1000000000] * 2 for _ in range(1000005)]
dp[0][0] = 0
n = len(s)
for i in range(n):
for j in range(2):
x = int(s[i])
x += j
if x < 10:
dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + x)
if x > 0:
dp[i + 1][1] = m... |
p02578 | s199590651 | Wrong Answer | N = int(input())
A = list(map(int, input().split()))
step = max(A)-min(A)
print(step) |
p02881 | s432220942 | Accepted | N = int(input())
dmin = N+N
for i in range(1,int(N**0.5)+1):
if N%i==0:
dmin = min(dmin,i+N//i-2)
print(dmin) |
p02796 | s969590849 | Accepted | # Keyence B
N = int(input())
robot_list = []
robot_count = 0
for _ in range(N):
x, l = map(int, input().split())
robot_list.append([x + l, x - l])
robot_list.sort()
r = - 10**9 - 1
for i in range(N):
if r <= robot_list[i][1]:
robot_count += 1
r = robot_list[i][0]
print(robot_count) |
p02647 | s805454179 | Accepted | from itertools import accumulate
n, k = map(int, input().split())
a = list(map(int, input().split()))
for j in range(k):
a01 = [0] * (n + 1)
for i, ai in enumerate(a):
l, r = max(0, i - ai), min(i + ai + 1, n)
a01[l] += 1
a01[r] -= 1
a = list(accumulate(a01))[:-1]
if all(ai == ... |
p03544 | s074685835 | Accepted | import sys
N = int(input())
if(N==1):
print(1)
sys.exit()
L=[2,1]
for i in range(N - 1):
t=L.pop(0) + L[0]
L.append(t)
print(L[-1]) |
p03672 | s541498353 | Wrong Answer | st=input()
for i in range(2,len(st),2):
r=st[0:i]
if r[0:i//2]==r[i//2:]:
print(i) |
p02688 | s490660198 | Accepted | # import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement
# import queue
# import heapq
def main():
N, K = map(int, input().split())
sunuke = [True for _ in range(N)]
for i in range(K):
d = input()
... |
p03639 | s336414385 | Wrong Answer | from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n = int(input())
a = list(map(int, input().split()))
c0 = 0
c4 = 0
for ai in a:
if ai % 2 != 0:
c0 += 1
if ai % 4 == 0:
c4 += 1
if c0 > c4 + 1:
print('No')
... |
p03352 | s668641566 | Wrong Answer | x=int(input())
b=[False for i in range(x)]
for i in range(1,x+1):
for j in range(2,x+1):
if i**j<=x:
b[i**j-1]=True
else:
break
for i in range(len(b),0,-1):
if b[i-1]==True:
print(i)
exit() |
p02743 | s235899113 | Wrong Answer | a,b,c=list(map(int,input().split()))
if (a**0.5+b**0.5)<(c**0.5):
print("Yes")
else:
print("No") |
p03331 | s423465733 | Accepted | n=int(input())
def sum0f(n):
sum=0
while n>0:
sum+=n%10
n//=10
return sum
list=[]
for a in range(1,n):
list.append(sum0f(a)+sum0f(n-a))
print(min(list))
|
p03067 | s523294427 | Accepted | A, B, C = map(int, input().split())
if A > B:
A, B = B, A
print("Yes") if A < C < B else print("No")
|
p02687 | s561783232 | Accepted | import numpy as np
import math
S = str(input())
if S == "ABC":
print("ARC")
else:
print("ABC") |
p03427 | s721902909 | Accepted | n = list(map(int, list(str(input()))))
ans = sum(n)
ans = max(ans, n[0] - 1 + 9 * (len(n) - 1))
print(ans) |
p03556 | s943051137 | Accepted | import math
n = int(input())
for i in range(n,0, -1):
if math.sqrt(i) - int(math.sqrt(i)) == 0:
print(i)
break |
p03338 | s688856884 | Accepted | N = int(input())
S = input()
ans = 0
for i in range(1, N):
X, Y = S[:i], S[i:]
temp = set(X) & set(Y)
ans = max(ans, len(temp))
print(ans)
|
p02897 | s768893744 | Wrong Answer | # N = int(input())
N=100
if N % 2 == 0:
print("0.5000000000")
else:
tmp = (N+1)/2
print(tmp/N)
|
p03433 | s220744617 | Wrong Answer | N = int(input())
A = int(input())
total = N
for i in range(1, 100):
if total - 500*i == 0:
print('Yes')
break
elif total - 500*i < 0:
total = total - 500*(i - 1)
break
if total - A > 0:
print('No')
else:
for j in range(A + 1):
total = total - 1
... |
p03338 | s684735958 | Accepted | N = int(input())
s = input()
max = 0
for i in range(1, len(s)):
u = len(set(s[:i]).intersection(set(s[i:])))
if u > max:
max = u
print(max) |
p03220 | s417301693 | Wrong Answer | n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
for i in range(n):
temp = 12 - h[i]*0.006
k = abs(a-temp)
if i == 0:
ans = i+1
else:
if k>temp:
ans = i+1
print(ans)
|
p02742 | s711882934 | Wrong Answer | H, W = [int(x) for x in input().split(" ")]
if H*W%2 == 0:
print(int(H*W/2))
else:
print(int(H*W/2)+1) |
p03556 | s979265076 | Accepted | import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return lis... |
p02910 | s059507918 | Wrong Answer | S = input()
s = list()
for a in S:
s.append(a)
even = s[1::2]
odd = s[0::2]
if 'L' in even and 'R' in odd:
print('Yes')
else:
print('No') |
p03998 | s141988037 | Wrong Answer | S = {'a':[], 'b':[], 'c':[]}
for char in ['a', 'b', 'c']:
S[char] = [c for c in input()]
# 今誰のターンか, 終了フラグ
now = 'a'
end = 0
while end == 0:
# もしもうカードがなければ終了
if len(S[now]) == 0 :
print(now)
end = 1
else :
# 先頭を取得しnow更新, 文字を詰める
now = S[now].pop(0) |
p03472 | s279137492 | Wrong Answer | N,H=list(map(int,input().split()))
a=[0]*N
b=[0]*N
for i in range(N):
ta,tb=list(map(int,input().split()))
a[i]=ta
b[i]=tb
amax=max(a)
b.sort(reverse=True)
res=10**10
csum=0
for i in range(N+1):
cnt=i
ch=H
csum+=b[i-1] if i>0 else 0
ch-=csum
if H>0:
cnt+=-(-ch//amax)
res... |
p02862 | s412608188 | Accepted | i, j = map(int, input().split())
if (i + j) % 3 != 0 or (max(i, j) / min(i, j) > 2):
print(0)
else:
TW = (i + j) // 3
W = (TW - (i-j)) // 2
def mod_cmb(n, r, mod=10**9+7):
r = min(r, n-r)
res = 1
for i in range(r):
res = res * (n - i) % mod * pow(i+1, mod-2, mod) % mod
return... |
p03131 | s635345663 | Accepted | # C - When I hit my pocket...
K, A, B = map(int, input().split())
if B - A <= 2:
print(1 + K)
else:
n_change = (K-(A-1)) // 2
if n_change == 0:
print(1 + K)
else:
print(n_change * B - (n_change-1) * A + (K - 2*n_change - (A-1))) |
p03250 | s422445155 | Accepted | A,B,C = map(int, input().split())
r = max(A,B,C)*9 + A+B+C
print(int(r)) |
p02553 | s387418292 | Wrong Answer | a,b,c,d = map(int,input().split())
if(b<0 or d<0):
if(b>=0 or d>=0):
print(0)
else:
print(a*b)
else:
print(b*d) |
p02693 | s530708903 | Wrong Answer | K = int(input())
AB = input()
l = AB.split()
A = int(l[0])
B = int(l[1])
li = []
for i in range(A, B+1) :
if i % K == 0 :
li.append(i)
else :
continue
if len(li) >=1 :
print("YES")
else :
print("NO") |
p03162 | s326819695 | Wrong Answer | N = int(input())
ans = 0
for i in range(N):
ans += max(list(map(int,input().split())))
print(ans) |
p02811 | s482340288 | Wrong Answer | k,x=map(int,input().split())
if 500*k > x:
print("Yes")
else:
print("No") |
p03633 | s967149062 | Wrong Answer | from fractions import gcd
from functools import reduce
def lcm(a,b):
return (a*b)//gcd(a,b)
def lcm_list(l):
return reduce(lcm, l)
def solve():
N = int(input())
T = [int(input()) for _ in range(N)]
print(lcm_list(T)) |
p02546 | s745677340 | Wrong Answer | x = input()
if x.endswith("s") == True:
x = x + "es"
else:
x = x + "s" |
p03672 | s841109515 | Accepted | s = input()
while (True):
s = s[:len(s) - 2]
ls = len(s)
if s[ls // 2:] == s[:ls // 2]:
break
print(len(s)) |
p02820 | s682696017 | Wrong Answer | N, K = map(int, input().split())
R, S, P = list(map(int, input().split()))
T = list(input())
result = [0] * N
for i,t in enumerate(T):
if t == "r":
result[i] = P
elif t == "s":
result[i] = R
else:
result[i] = S
for i in range(K-1, N):
if result[i] == result[i-K]:
result... |
p03761 | s965043423 | Wrong Answer | n=int(input())
abc=list("abcdefghijklmnopqrstuvwxyz")
D={}
for a in abc:
D[a]=0
for i in range(n):
s=input()
for a in abc:
now=D[a]
num=s.count(a)
if i==0:
D[a]=num
else:
D[a]=min(now,num)
ans=""
for s,v in D.items():
ans+=s*v
print(ans)
|
p02982 | s280539495 | Wrong Answer | import sys,math
input = sys.stdin.readline
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
for j in range(N):
num = 0
if i < j:
for k in range(D):
num += pow(abs(X[i][k] - X[j][k]) ,2)
if math.floor(math.sqrt(num)) ** 2 == n... |
p03862 | s134502098 | Wrong Answer | n,x = map(int,input().split())
L = list(map(int,input().split()))
cnt = 0
L = [0]+L+[0]
for i in range(1,n+1):
a = L[i-1] + L[i+1]
if a >= x:
cnt +=a-x
if i !=1:
L[i-1],L[i+1] = x, 0
else:
L[i-1],L[i+1] = 0, x
print(cnt)
|
p02676 | s936855738 | Wrong Answer | K = int(input("enter a number: "))
S = input("enter a random string: ")
def f(K, S):
if 0 < K < 101 and 0 < len(S)+1 < 101:
if len(S) < K:
return S
else:
M = len(S) - K
return S[0:M] + "..."
elif K > 100 or K < 1:
return "Please choose an interger from... |
p02897 | s133980998 | Accepted | a = int(input())
print((a - a//2) / a) |
p03243 | s086864195 | Wrong Answer | n=int(input())
if n%111==0:
print(n)
else:
print((n//111)+1) |
p02859 | s398244464 | Wrong Answer | def f(r):
print(r**2)
|
p03377 | s892898839 | Accepted | arr = input().split()
arr = list(map(int, arr))
a = arr[0]
b = arr[1]
x = arr[2]
if a <= x and x <= a+b:
print('YES')
else:
print('NO')
|
p02576 | s370828006 | Wrong Answer | a, b, c = map(int, input().split())
if a%b == 0:
d = a / b
else:
d = int(a / b) + 1
print("{}".format(d * c)) |
p02971 | s146565043 | Accepted | N,*A =map(int,open(0).read().split())
B =sorted(A)
biggest = B[-1]
for i in A:
if i==biggest:
print(B[-2])
else:
print(biggest) |
p02854 | s977837388 | Accepted | n = int(input())
a = [int(s) for s in input().split()]
sum1 = 0
count = 0
total_length = sum(a)
for i in range(len(a)):
sum1 += a[i]
if sum1 >= total_length / 2:
count1 = abs(sum1 - sum(a[i + 1:]))
count2 = abs(sum1 - a[i] - sum(a[i:]))
if count1 <= count2:
count = count1
... |
p02618 | s061562729 | Accepted | import numpy as np
D = int(input())
c = np.array( list(map(int, input().split())) )
#
s = [[] for i in range(D)]
for i in range(D):
s[i] = np.array( list(map(int, input().split())) )
#
v = 0
cc = np.array( [0]*26 )
last = np.array( [-1]*26 )
for d in range(D):
cc += c
av = s[d] - sum( cc ) + cc
av2 = av + cc*... |
p03339 | s226428189 | Accepted | N = int(input())
A = input()
w = [A[0] == "W"]
for i in range(1, N): w.append(w[-1] + (A[i] == "W"))
e = [A[0] == "E"]
for i in range(1, N): e.append(e[-1] + (A[i] == "E"))
ans = min(e[-1] - e[0], w[-2])
for i in range(1, N - 1): ans = min(ans, w[i - 1] + e[-1] - e[i])
print(ans) |
p02618 | s357210532 | Accepted | import random
import sys
import time
input = sys.stdin.readline
def main():
# start_time = time.time()
# while True:
# elapsed_time = time.time() - start_time
# if elapsed_time >= 2.0:
# print(elapsed_time)
# return 0
d = int(input())
c = list(map(int, input().s... |
p03106 | s364918618 | Accepted | A,B,K = map(int,input().split())
i = 1
S =[]
while i <= min(A,B):
if A%i ==0 and B%i == 0:
S.append(i)
i += 1
print(S[-K]) |
p02608 | s617663959 | Accepted | import numpy as np
n = int(input())
res = [0]*(n+1)
for i in range(1,101):
for j in range(1,101):
for k in range(1,101):
x = i*i + j*j + k*k + i*j + j*k + k*i
if x <= n:
res[x] += 1
for i in range(1,n+1):
print(res[i])
|
p03095 | s592452124 | Accepted | n = int(input())
s = input()
mod = 1000000007
alphacnt = [0]*26
ans = 0
for c in s[::-1]:
idx = ord(c)-ord("a")
alphacnt[idx] += 1
cnt = 1
for i in range(26):
if i == idx: continue
cnt = (cnt*(alphacnt[i]+1))%mod
ans = (ans+cnt)%mod
print(ans) |
p02597 | s844737538 | Accepted | n = int(input())
s = input()
r = 0
w = 0
for i in range(n):
if(s[i] == "R"): r += 1
else: w += 1
ngr = 0
ngw = 0
for i in range(n):
if(i < r and s[i] == 'W'): ngw += 1
if(i >= r and s[i] == 'R'): ngr += 1
print(min(ngw, ngr) + abs(ngw-ngr)) |
p02713 | s372067392 | Accepted | import math
k = int(input())
kl = [i for i in range(1, k+1)]
total = 0
dp = {}
for i in kl:
for j in kl:
tmp = math.gcd(i, j)
for k in kl:
total += math.gcd(tmp, k)
print(total)
|
p03645 | s283905715 | Wrong Answer | n, m = map(int, input().split())
arr_ = [tuple(map(int, input().split())) for _ in range(m)]
one = set([b for a, b in arr_ if a == 1])
last = set([a for a, b in arr_ if b == n])
connect = one & last
print("POSSIBLE" if len(connect) >= 1 else "POSSIBLE") |
p03437 | s840375713 | Wrong Answer | x,y=map(int,input().split())
if y%x==0:
print(-1)
else:
print(x) |
p03345 | s419044612 | Accepted | A,B,C,K = list(map(int,input().split()))
if abs(A-B) > 10**18:
print('Unfair')
exit()
if K % 2 == 0:
print(A-B)
else:
print(B-A) |
p02952 | s579183732 | Accepted | n = int(input())
count = 0
for i in range(1, n+1):
if len(str(i)) % 2 == 1:
count += 1
print(count) |
p02548 | s852461767 | Accepted | N = int(input())
count = 0
for a in range(1, N):
ans, mod = divmod(N, a)
if mod == 0:
count += ans - 1
else:
count += ans
print(count) |
p02948 | s891871245 | Wrong Answer | # coding: utf-8
import heapq
n, m = map(int, input().split())
jobs = [[] for i in range(m)]
for i in range(n):
a, b = map(int, input().split())
if a > m:
continue
jobs[m-a].append(b)
ans = 0
l = []
for i in range(m-a, -1, -1):
for j in jobs[i]:
heapq.heappush(l, -j)
if len(l):
... |
p02658 | s210987080 | Accepted | n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
for i in a:
ans *= i
if ans > pow(10, 18):
print(-1)
exit()
print(ans) |
p04011 | s358846621 | Accepted | n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
if n > k:
print((n - k) * y + k * x)
else:
print(n * x) |
p03815 | s459198686 | Accepted | N = int(input())
ans = N // 11 * 2
N %= 11
if N == 0:
print(ans)
elif N <= 6:
print(ans+1)
else:
print(ans+2) |
p03625 | s479124286 | Wrong Answer | N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
HW = []
PCN = [-1]*3
for i in range(1,N):
PCN[:1]=PCN[1:]
PCN[2]=A[i]
if PCN[2]==PCN[1] and PCN[1]!=PCN[0]:
n = A.count(A[i])
HW += [A[i]]*(n//2)
if len(HW)>=2:
break
HW = HW + [0,0]
print(HW[0]*HW[1]) |
p02711 | s443981682 | Accepted | print('Yes' if '7' in input() else 'No') |
p03524 | s896188094 | Accepted | s = input()
x = len(s)
a = s.count('a')
b = s.count('b')
c = s.count('c')
if x % 3 == 0:
if a == b == c:
print('YES')
else:
print('NO')
elif x % 3 == 1:
if a == b + 1 == c + 1 or b == a + 1 == c + 1 or c == a + 1 == b + 1:
print('YES')
else:
print('NO')
else:
if a == b == c + 1 or b == c == a... |
p03071 | s290196501 | Wrong Answer | a, b = map(int, input().split())
ans = max(a, b)
if a-1 > b:
ans += a-1
elif a < b-1:
ans += b-1
else: ans += a
print(ans) |
p02594 | s780583616 | Accepted | x = int(input())
if x <30:
print("No")
else:
print("Yes") |
p02765 | s160255034 | Accepted | N, R = map(int, input().split())
if N >= 10: print(R)
else: print(R + 100*(10-N)) |
p02939 | s578009408 | Accepted | # A - Dividing a String
S = input()
arr = [S[0]]
i = 1
while i < len(S):
s = S[i]
if s == arr[-1]:
if i + 1 < len(S):
i += 1
s += S[i]
else:
arr[-1] += s
break
arr.append(s)
i += 1
print(len(arr)) |
p03455 | s688851851 | Accepted | a,b =(int(x) for x in input().split())
if (a*b)%2==0:
print("Even")
else:
print("Odd")
|
p03767 | s160199638 | Accepted | N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
for i in range(N):
ans += int(a[2*i+1])
print(ans) |
p03827 | s048663612 | Accepted | N = int(input())
S = str(input())
ans = 0
tmp = 0
for i in range(N):
if S[i] == 'I':
tmp += 1
else:tmp -= 1
ans = max(ans,tmp)
print(ans) |
p02594 | s192150005 | Accepted | X = int(input())
if X >= 30:
print('Yes')
else:
print('No') |
p02727 | s778932012 | Accepted | X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
r.sort()
r.reverse()
total=[]
for i in range(X):
total.append(p[i])
for i in range(Y):
total.append(q[i])
for i in range(C):
total.a... |
p02760 | s221848509 | Accepted | bingo=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
D=[[0]*3 for _ in range(3)]
for _ in range(N):
b=int(input())
for i in range(3):
for j in range(3):
if b==bingo[i][j]:
D[i][j]=1
ans=set()
for d in D:
ans.add(sum(d))
for d in zip(*D):
ans.add(su... |
p02627 | s117723567 | Accepted | s = input()
print('A' if s.isupper() else 'a') |
p03160 | s884575417 | Accepted | n = int(input())
h = list(map(int, input().split()))
cnt = [float('inf')]*n
cnt[0], cnt[1] = 0, abs(h[0]-h[1])
for i in range(2,n):
cnt[i]=min(abs(h[i-1]-h[i])+cnt[i-1],abs(h[i-2]-h[i])+cnt[i-2])
print(cnt[n-1])
|
p02958 | s861981385 | Accepted | n = int(input())
p = list(map(int,input().split()))
sort_p = sorted(p)
ans = "YES"
c = 0
for n,m in zip(p,sort_p):
if n != m:
c += 1
if c > 2:
ans = "NO"
print(ans)
|
p02773 | s009987907 | Accepted | from collections import Counter
n=int(input())
a=[]
for i in range(n):
a.append(input())
ac=Counter(a)
acs=sorted(ac.items(),key=lambda x:x[1],reverse=1)
z=len(acs)
i=0
temp=[]
while i<=z-1 and acs[i][1]==acs[0][1] :
temp.append(acs[i][0])
i+=1
temp.sort()
for i in temp:
print(i) |
p03076 | s842477855 | Accepted | etime=[]
for i in range(5):
etime.append(int(input()))
atime=[int(((i-1)//10+1)*10) for i in etime]
A=sum(atime)
c=[]
for k in range(5):
c.append(A-atime[k]+etime[k])
print(min(c))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.