problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p03160
s546910919
Wrong Answer
n = int(input()) h = list(map(int, input().split())) import numpy as np d = [0] * n #ex. [0, 0, 0, 0, 0, 0] d[1] = np.abs(h[1] - h[0]) for i in range(n-2): d[i+2] = min(d[i] + np.abs(h[i+2] - h[i]), d[+1] + np.abs(h[i+1] - h[i+2])) print(d[n-1])
p03160
s897549888
Wrong Answer
N = int(input()) h = list(map(int,input().split())) dp = [10**5 for _ in range(N)] dp[0] = 0 for i in range(N-1): dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1] -h[i])) if i+2 < N: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] -h[i])) print(dp[-1])
p03160
s788530707
Wrong Answer
n = int(input()) h = list(map(int, input().split())) dp = [float('inf')] * n dp[0] = 0 dp[1] = abs(h[0] - h[1]) for i in range(2, n - 1): dp[i] = min((dp[i - 2] + abs(h[i - 2] - h[i])), (dp[i - 1] + abs(h[i - 1] - h[i]))) print(dp[n - 1])
p03160
s015793225
Wrong Answer
N = int(input()) H = list(map(int, input().split())) INF = 100000 dp = [INF] * N dp[0] = 0 for i in range(N-1): dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1])) if i <= N - 3: dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2])) print(dp[N - 1])
p03160
s761724543
Wrong Answer
N=int(input()) h=list(map(int,input().split(' '))) h2=[[0,0]] h2.append([abs(h[0]-h[1]),0]) for i in range(0,len(h)-2): if abs(h[i+1]-h[i+2]) >= abs(h[i]-h[i+2]): h2.append([abs(h[i]-h[i+2]),i]) else: h2.append([abs(h[i+1]-h[i+2]),i+1]) a=h2[int(len(h2)-1)][1] total=h2[int(len(h2)-1)][0] while a...
p03160
s358490369
Wrong Answer
n=int(input()) arr=[int(x) for x in input().split()] arr.append(0) val=[0]*(n+1) for i in range(n-2,-1,-1): val[i]=min(abs(arr[i]-arr[i+1])+val[i+1],abs(arr[i]-arr[i+2])+val[i+2]) print(val[0])
p03160
s688842483
Wrong Answer
N = int(input()) *h, = map(int, input().split()) dp = [0] * N dp[1] = h[1] - h[0] for i in range(2, N): c1, c2 = abs(h[i - 1] - h[i]) + dp[i - 1], abs(h[i - 2] - h[i]) + dp[i - 2] if c1 < c2: dp[i] = c1 else: dp[i] = c2 print(dp[N - 1])
p03160
s685883658
Wrong Answer
def main(): N = int(input()) H = [int(x) for x in input().split()] inf=float("inf") DP = [float("inf")]*N DP[0] = H[0] DP[1] = abs(H[1]-H[0]) for i in range(2,N): DP[i] = min(DP[i-1]+abs(H[i]-H[i-1]),DP[i-2]+abs(H[i]-H[i-2])) print(DP[-1]) if __name__ == "__main__": ma...
p03160
s558388925
Wrong Answer
n=int(input()) l=list(map(int,input().split())) dp=[0]*(n) dp[0]=0 dp[1]=abs(l[0]-l[1]) for i in range(2,n): dp[i]=max(abs(l[i]-l[i-2])+dp[i-2],dp[i-1]+abs(l[i]-l[i-1])) print(dp[-1])
p03160
s430481542
Wrong Answer
N = int(input()) list = [int(i) for i in input().split(" ")] def cost(N): dp = [0] * N dp[0] = list[0] dp[1] = abs(list[1]-list[0]) for i in range(2,N): dp[i] = min([dp[i-1]+abs(list[i-1]-list[i]),dp[i-2]+abs(list[i-2]-list[i])]) return dp[N-1] print(cost(N))
p03160
s111562541
Wrong Answer
inp = int(input()) if inp>=400 and inp<=599: print(8) elif inp>=600 and inp<=799: print(7) elif inp>=800 and inp<=999: print(6) elif inp>=1000 and inp<=1199: print(5) elif inp>=1200 and inp<=1399: print(4) elif inp>=1400 and inp<=1599: print(3) elif inp>=1600 and inp<=1799: print(2) elif inp>=1800 and inp...
p03160
s717684206
Wrong Answer
from sys import stdin import sys import math from functools import reduce import functools import itertools from collections import deque,Counter from operator import mul import copy # ! /usr/bin/env python # -*- coding: utf-8 -*- import heapq n = int(input()) h = [0] + list(map(int, input().split())) INF = 10**15 d...
p03160
s310132480
Wrong Answer
N=int(input()) h=list(map(int,input().split())) INF = float('inf') dp = [INF] * N dp[1]=abs(h[1]-h[0]) for i in range(2,N): dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) print(dp[-1])
p03160
s593739713
Wrong Answer
N = int(input()) H = list(map(int, input().split())) dp = [0] * (N+1) dp[1] = H[0] for i in range(2,N): dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2])) res = dp[N] print(res)
p03160
s918396442
Wrong Answer
def func(arr): crr=[0 for i in range(len(arr))] crr[0]=0 crr[1]=abs(arr[1]-arr[0]) for i in range(2,len(arr)): crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2]) print(crr) b=input() cr=list(map(int,input().split())) func(cr)
p03160
s982679851
Wrong Answer
N=int(input()) A=list(map(int,input().split())) dp=[float("INF")]*N dp[0]=0 dp[1]=abs(A[0]-A[1]) for i in range(2,N): dp[i]=min(dp[i],abs(A[i]-A[i-1]),abs(A[i-2]-A[i])) print(dp[-1])
p03160
s713434433
Wrong Answer
N=int(input()) h=input().split() i = N-1 sum = 0 while i > 1: if abs(int(h[i]) - int(h[i-1])) < abs(int(h[i]) - int(h[i-2])): sum += abs(int(h[i]) - int(h[i-1])) i -=1 else: sum += abs(int(h[i]) - int(h[i-2])) i-=2 if i == 1: sum += abs(int(h[1]) - int(h[0])) print(sum)
p03160
s085831712
Wrong Answer
INF = 10**5 N = int(input()) height = list(map(int, input().split())) cost = [INF]*N cost[0] = 0 cost[1] = min(cost[1], cost[0]+abs(height[1]-height[0])) for i in range(2, N): cost[i] = min(cost[i], cost[i-1]+abs(height[i]-height[i-1]), cost[i-2]+abs(height[i]-height[i-2])) print(cost[N-1])
p03160
s617882712
Wrong Answer
n = int(input()) h = list(map(int,input().split())) dp = [10**8]*n dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(1,n): dp[i] = min(dp[i],dp[i-1] + abs(h[i] - h[i-1])) if i >= 2: dp[i] = min(dp[i],dp[i-2] + abs(h[i] - h[i-2])) print(dp[-1])
p03160
s598503166
Wrong Answer
N = int(input()) H = list(map(int, input().split())) dp = [float('inf')] * N dp[0] = 0 for i in range(1, N): dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]) ) if i >= 2 else dp[i-1] + abs(H[i] - H[i-1]) print(*dp) print(dp[N-1])
p03160
s151648673
Wrong Answer
n=int(input()) arr=list(map(int,input().split())) if n < 2: print(0) vis={} vis[0] = 0 vis[1] = 0 if n > 1: vis[2] = abs(arr[0]-arr[1]) if n == 2: print(vis[2]) for i in range(3, n+1): step_1 = abs(arr[i-1]-arr[i-2]) + vis[i-1] step_2 = abs(arr[i-1]-arr[i-3]) + vis[i-2] vis[i] = min(step_1, step_2) ...
p03160
s224444242
Wrong Answer
n=int(input()) a=list(map(int,input().split())) ans=0 i=n-1 while(i>1): k=min(abs(a[i-2]-a[i]),abs(a[i-1]-a[i])) ans+=k if abs(a[i-2]-a[i])<=abs(a[i-1]-a[i]): i-=2 else: i-=1 if i==1: ans+=abs(a[0]-a[1]) print(ans)
p03160
s414776889
Wrong Answer
a = int(input()) hs = [int(x) for x in input().split()] dp = [1000000000]* len(hs) dp[0] = 0 dp[1] = abs(hs[1] - hs[0]) for i in range(a): if i + 1 < len(hs): dp[i+1] = min(abs(hs[i+1]- hs[i]), dp[i+1]) if(i+2 < len(hs)): dp[i+2] = min(abs(hs[i+2]- hs[i]), dp[i+2]) print(dp[-1])
p03160
s302404029
Wrong Answer
n = int(input()) arr = [int(i) for i in input().split()] dp = [0 for i in range(n)] print(dp) for i in range(1,n): op1 = abs(arr[i]-arr[i-1]) + dp[i-1] op2 = abs(arr[i]-arr[i-2]) + dp[i-2] if i != 1 else float("inf") dp[i] = min(op1,op2) print(dp[n-1])
p03160
s636127421
Wrong Answer
n = int(input()) a = list(map(int, input().split())) dp = [float('inf')]*n dp[0] = 0 for i, v in enumerate(a): if i > n - 1: break if i - 2 < 0: dp[i] = abs(a[i] - a[i-1]) continue one_step_cost = dp[i-1] + abs(a[i] - a[i-1]) two_step_cost = dp[i-2] + abs(a[i] - a[i-2]) dp[i] = min(one_step_cost...
p03160
s718889257
Wrong Answer
dp = {} n = int(input()) h = [int(x) for x in input().split()] dp[0] = 0 dp[1] = h[1] - h[0] for x in range(2, n): dp[x] = min( dp[x - 1] + abs(h[x] - h[x - 1]), dp[x - 2] + abs(h[x] - h[x - 2]) ) print(dp[n-1])
p03160
s897598597
Wrong Answer
N=int(input()) h=list(map(int,input().split())) i=0 s=0 while(i<N): d1=0 d2=0 if(i+1<N): d1=abs(h[i]-h[i+1]) if(i+2<N): d2=abs(h[i]-h[i+2]) if(d1<d2): s+=d1 i+=1 else: s+=d2 i+=2 print(s)
p03160
s081949075
Wrong Answer
n = int(input()) h = [i for i in map(int, input().split())] f_inf = float('inf') DP = [f_inf]*n DP[0] = 0 DP[1] = h[1]-h[0] for i in range(n-2): if abs(h[i+2] - h[i]) < abs(h[i+2] - h[i+1]): DP[i+2] = DP[i] + abs(h[i+2] - h[i]) else: DP[i+2] = DP[i+1] + abs(h[i+2] - h[i+1]) print(DP[-1])
p03160
s615726910
Wrong Answer
def chmin(a, b): if a > b: return b else: return a def main(): dp = [1e8]*100010 hs = [0]*100010 N = int(input()) hs[:N] = map(int, input().split()) dp[0] = 0 for i in range(N): dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i])) dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i])) ...
p03160
s789439059
Wrong Answer
n = int(input()) lis = list(map(int,input().split(' '))) def sol(lis): if len(lis)<=2: return abs(lis[0]-lis[1]) costs = [0,abs(lis[0]-lis[1])] for i in range(2,len(lis)): x = abs(lis[i]-lis[i-1]) y = abs(lis[i]-lis[i-2]) if x<y: costs.append(x+costs[-1]) ...
p03160
s467456323
Wrong Answer
N = int(input()) Hs = list(map(int, input().split())) dp = [2 ** 32] * (N + 1) dp[0] = 0 for i in range(N): for j in range(1, 3): if i + j < N: dp[i+j] = min(dp[i+j], dp[i] + abs(Hs[i+j]-Hs[i])) print(dp[N])
p03160
s656356110
Wrong Answer
n = int(input()) h = list(map(int, input().split(' '))) dp = [0]+[100000]*(n-1) for i in range(0,n): if i+1<=n-1: dp[i+1] = min(dp[i]+abs(h[i]-h[i+1]), dp[i+1]) if i+2<=n-1: dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]), dp[i+2]) print(dp[-1])
p03160
s292215967
Wrong Answer
N=int(input()) S=list(map(int,input().split())) for i in range(10): S.append(10**12) DP=[10*12]*100010 DP[0]=0 for i in range(N): if DP[i+1]>DP[i]+abs(S[i+1]-S[i]): DP[i+1]=DP[i]+abs(S[i+1]-S[i]) if DP[i+2]>DP[i]+abs(S[i+2]-S[i]): DP[i+2]=DP[i]+abs(S[i+2]-S[i]) print(DP[N-1]) ...
p03160
s936203414
Wrong Answer
n = int(input()) *h, = map(int, input().split()) dp = [float("inf")]*n dp[0] = 0 for i in range(1, n): if i == 1: dp[i] = dp[i-1] + abs(h[i-1] - h[i]) else: dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i])) print(dp)
p03160
s933322366
Wrong Answer
N=int(input()) l=[int(x) for x in input().split()] l1=[999999]*(N+1) l1[0]=0 for i in range(N): for j in range(i+1,i+3): if j<N: l1[j]=min(l1[j],l1[i]+abs(l[j]-l[i])) print(l1[N-1])
p03160
s736161223
Wrong Answer
import sys def I(): return int(sys.stdin.readline().rstrip()) def IL(): return map(int,sys.stdin.readline().rstrip().split()) def Main(): n = I() h = list(IL()) l = [1e5]*n l[0] = 0 for i in range(1,n): l[i] = min(l[i],l[i-1]+abs(h[i-1]-h[i])) if 1<i: l[i] = min(l[i],l[i...
p03160
s596117891
Wrong Answer
n=int(input()) a=list(map(int,input().split())) ans=0 i=0 while(i<n-2): k=min(abs(a[i+2]-a[i]),abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1])) ans+=k if abs(a[i+2]-a[i])<=abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]): i+=2 else: i+=1 if i==n-2: ans+=abs(a[n-1]-a[n-2]) print(ans)
p03160
s124227924
Wrong Answer
n = int(input()) l = list(map(int, input().split())) diff = 0 prev = l[0] i = 1 while(i < n-1): diff += abs(prev-min(l[i],l[i+1])) prev = min(l[i],l[i+1]) if(prev == l[i]): i += 1 else: i += 2 print(diff)
p03160
s474562746
Wrong Answer
def kodokBedindang(watu): if len(watu) == 1: return 0 elif len(watu) == 2: return abs(watu[0]-watu[1]) else: one = abs(watu[0] - watu[1]) two = abs(watu[0] - watu[2]) if two <= one: return two + kodokBedindang(watu[2::]) else: return o...
p03160
s832234973
Wrong Answer
#DP カエルの奴 A  配るDP N=int(input()) S=list(map(int,input().split())) S.append(100010) S.append(100010) DP=[100000000]*100010 DP[0]=0 for i in range(N): if DP[i]+abs(S[i]-S[i+1])<DP[i+1]: DP[i+1]=DP[i]+abs(S[i]-S[i+1]) if DP[i]+abs(S[i]-S[i+2])<DP[i+2]: DP[i+2]=DP[i]+abs(S[i]-S[i+2]) print(DP[N-1...
p03160
s663385562
Wrong Answer
# -*- coding: utf-8 -*- """ Created on Wed May 13 12:16:43 2020 @author: PREET MODH """ input() a=list(map(int,input().split())) i=0 sum=0 a.append(10000000000) while(i+2<len(a)): if i >=len(a): break b=a[i] store=min(a[i+1],a[i+2]) diff=abs(b-store) sum=sum + diff if a[i+1]<a[i+2]: ...
p03160
s802968415
Wrong Answer
n = int(input()) a = list(map(int, input().split())) a.append(99999) dp = [0] * (n+1) dp[0] = 0 for i in range(n): print(dp) if (i > 0): dp[i+1] = min(dp[i] + abs(a[i]-a[i+1]), dp[i-1] + abs(a[i-1]-a[i+1]) ) else: dp[i+1] = dp[i] + abs(a[i]-a[i+1])
p03160
s299250922
Wrong Answer
n=int(input()) arr=list(map(int,input().split())) if n < 2: print(0) vis={} vis[0] = 0 vis[1] = 0 if n > 1: vis[2] = abs(arr[0]-arr[1]) if n == 2: print(vis[2]) for i in range(3, n+1): step_1 = abs(arr[i-1]-arr[i-2]) + vis[i-1] step_2 = abs(arr[i-1]-arr[i-3]) + vis[i-2] vis[i] = min(step_1, step_2) ...
p03160
s177681733
Wrong Answer
n = int(input()) h = [int(i) for i in input().split()] cost = [9999 for i in range(n)] cost[:2] = 0, h[0] for i in range(2, n): cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]), cost[i-2] + abs(h[i]-h[i-2])) print(cost[-1])
p03160
s508122582
Wrong Answer
n = int(input()) l = list(map(int, input().split())) l1 = [0]*n for i in range(1,n): l1[i] = min(l[i], abs(l[i]-l[i-1])) print(l)
p03160
s968619345
Wrong Answer
N = int(input()) H = list(map(int, input().split())) dp = [0] * (N+1) dp[1] = 1 for i in range(2,N): dp[i] = min(dp[i-1], dp[i-2]) + 1 res = dp[N] print(res)
p03160
s579780046
Wrong Answer
N = int(input()) h = [0] + list(map(int, input().split())) dp = [0] * (N+1) for i in range(2, N+1): dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2])) print(dp[N])
p03160
s413800582
Wrong Answer
N = int(input()) h = list(map(int, input().split(" "))) dp = [1000000 for i in range(N)] dp[0] = 0 for i in range(N-1): dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i]) if i + 2 < N: dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i]) print(dp[-1])
p03160
s869518593
Wrong Answer
import numpy as np N = int(input()) h = list(map(int, input().split())) dp = np.full(N, np.inf) dp[0] = 0 for i in range(1,N): dp[i] = min(dp[i],dp[i-1]+np.abs(h[i] - h[i-1])) if i > 1: dp[i] = min(dp[i],dp[i-2]+np.abs(h[i] - h[i-2])) print(dp[-1])
p03160
s307310922
Wrong Answer
N = int(input()) h = list(map(int, input().split())) INF = 10 ** 5 + 1 dp = [INF] * N dp[0] = 0 for i in range(N): if i - 2 >= 0 and dp[i] > dp[i-2] + abs(h[i] - h[i-2]): dp[i] = dp[i - 2] + abs(h[i] - h[i - 2]) if i - 1 >= 0 and dp[i] > dp[i - 1] + abs(h[i] - h[i - 1]): dp[i] = dp[i - 1] + abs(h[i] - h[i...
p03160
s464373194
Wrong Answer
N = int(input()) h = list(map(int,input().split())) cost = [1000000]*(N+10) cost[0] = 0 for i in range(1, N): cost[i] = min(abs(h[i-1] - h[i]), cost[i]) if i < N - 2: cost[i+1] = min(abs(h[i-1] - h[i+1]), cost[i+1]) print(cost[N-1])
p03160
s363151238
Wrong Answer
def chmin(a, b): if a > b: return b else: return a def main(): dp = [1e4+10]*100010 hs = [0]*100010 N = int(input()) hs[:N] = map(int, input().split()) dp[0] = 0 for i in range(N): dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i])) dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i])) ...
p03160
s039153687
Wrong Answer
N=int(input()) h=list(map(int,input().split())) dp=[10**5]*(N) dp[0]=0 for i in range(1,N): dp[i]= min(dp[i-1]+abs(h[i]-h[i-1]),dp[i]) if i > 1: dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2])) print(dp[-1])
p03160
s872424695
Wrong Answer
import sys sys.setrecursionlimit(10**7) N = int(input()) h = list(map(int, input().split())) dp = [-1] * N # dp[i] := i から N-1 までの移動にかかる最小コスト dp[N-1] = 0 for i in reversed(range(N - 1)): if i == N - 2: dp[i] = dp[i + 1] + abs(h[i + 1] - h[i]) else: dp[i] = min(dp[i + 2] + abs(h[i + 2] - h[i])...
p03160
s220567158
Wrong Answer
n = int(input()) height = list(map(int, input().split())) dis = [0] * n dis[1] = height[1] - height[0] for i in range(2,n): dis[i] = min(dis[i-2] + abs(height[i] - height[i-2]), dis[i-1] + abs(height[i] - height[i-1])) print(dis[-1])
p03160
s059416686
Wrong Answer
n = int(input()) h = [int(i) for i in input().split()] cost = [None for i in range(n)] cost[:2] = 0, h[0] for i in range(2, n): cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]), cost[i-2] + abs(h[i]-h[i-2])) print(cost[-1])
p03160
s381584327
Wrong Answer
n = int(input()) x =list(map(int,input().split())) a = [0,abs(x[1]-x[0])] if n>2: for i in range(2,n): a.append(min(abs(x[i]-x[i-2])+a[-2],abs(x[i]+x[i-1])+a[-1])) else: print(a[-1]) exit() print(a[-1])
p03160
s409286053
Wrong Answer
def main(): n = int(input()) hs = list(map(int, input().split())) INF = 10 ** 12 dp = [INF] * n dp[0] = 0 dp[1] = hs[1] - hs[0] for i in range(2, n): dp[i] = min(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1])) dp[i] = min(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2])) print(dp[...
p03160
s862728742
Wrong Answer
def frog(): return 1
p03160
s639083418
Wrong Answer
n = int(input()) h = list(map(int, input().split())) dp = [0, abs(h[1]-h[0])] for i in range(2, n-1): dp.append(min(dp[i-1] + abs(h[i]-h[i+1]), dp[i-2] + abs(h[i-2]-h[i]))) dp.append(dp[n-2] + abs(h[n-1]-h[n-2])) print(dp[n-1])
p03160
s770026641
Wrong Answer
n = int(input()) h = list(map(int,input().split())) INF = 10 ** 20 dp = [INF]*(n) dp[0] = 0 dp[1] = h[1]-h[0] for i in range(2,n): dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print(dp[n-1])
p03160
s965366904
Wrong Answer
N = int(input()) H = list(map(int, input().split())) dp = [0] * (N+1) dp[1] = H[0] for i in range(2,N): dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+(H[i]-H[i-2])) res = dp[N] print(res)
p03160
s024057426
Wrong Answer
def chmin(a, b): if a > b: a = b return a else: return a n = int(input()) ls = list(map(int, input().split())) dp = [100010] * n dp[0] = 0 for i in range(1, n): dp[i] = chmin(dp[i], dp[i - 1] + abs(ls[i] - ls[i - 1])) if i > 1: dp[i] = chmin(dp[i], dp[i - 2] + abs(ls[...
p03160
s945794671
Wrong Answer
n = int(input()) h = list(map(int,input().split())) c = [0]*n c[1]=abs(h[1]-h[0]) for i in range(2,n): c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1])) print(h,c)
p03160
s944444377
Wrong Answer
N=int(input()) h=list(map(int,input().split())) # N = 4 # h = [10, 30, 40, 20] dp = [1000000]*N #d[i]はカエルが足場iへと移動するのに必要な最小コスト dp[0]=0 for i in range(1,N): if i == 1: dp[i] = dp[i-1]+abs(h[i]-h[i-1]) else: dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print(dp) print("min cost="...
p03160
s215540289
Wrong Answer
def find_min_cost(n, heights): if n == 1: return 0 min_costs = [None] * n # Base case - First stone min_costs[0] = 0 # Baze case - Second stone min_costs[1] = abs(heights[1] - heights[0]) for i in range(2, n): min_costs[i] = min( abs(heights[i] - heights[i-2])...
p03160
s150165277
Wrong Answer
# 方針: 少ないコストの選択をbacktrack N = int(input()) h = [int(val) for val in input().split(' ')] i = 1 total_cost = 0 while i < len(h): if i == len(h)-1: total_cost += abs(h[-i] - h[-i-1]) break step1_cost = abs(h[-i] - h[-i-1]) step2_cost = abs(h[-i] - h[-i-2]) if step1_cost < step2_cost: ...
p03160
s664551610
Wrong Answer
n=int(input()) arr=list(map(int,input().split())) print(arr)
p03160
s150054962
Wrong Answer
def frogOne(N, arr): dparr = [-1 for i in range(N)] dparr[0] = 0 dparr[1] = abs(arr[0]-arr[1]) for num in range(2, N): dparr[num] = min(dparr[num-2]+abs(arr[num-2]), dparr[num-1]+abs(arr[num]-arr[num-1])) return dparr[-1]
p03160
s259600270
Wrong Answer
# A - Frog1 import numpy as np N = int(input()) h = list(map(int, input().split())) dp = [10000000]*(N+2) dp[0] = 0 for i in range(N): if i+1<N: dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i])) if i+2<N: dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i])) print(dp[N-1])
p03160
s154436180
Wrong Answer
n = int(input()) h = list(map(int, input().split())) INF = 10**8 dp = [INF]*n dp[0] = 0 for i in range(n): if i+1 < n: dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i])) if i+2 < n: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i])) print(dp[n-1])
p03160
s304887982
Wrong Answer
n = int(input()) l = list(map(int, input().split())) dp = [0 for i in range(n)] dp[1] = abs(l[1]-l[0]) for i in range(2,n): dp[i] = min(dp[i-1] + abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-1])) print(dp[-1])
p03160
s796631800
Wrong Answer
n = int(input()) h = list(map(int, input().split())) h.append(99999999) h.append(99999999) dp = [999999] * (n + 2) dp[0] = 0 for i in range(n): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1])) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2])) print(dp[n - 1])
p03160
s903280154
Wrong Answer
n = int(input()) his = list(map(int, input().split())) dp = [] for i in range(n): dp.append(0) for i in range(0, n): if i >= 2: dpm1 = abs(his[i] - his[i-1]) dpm2 = abs(his[i] - his[i-2]) if dpm1 <= dpm2: dp[i] = dp[i-1] + dpm1 else: dp[i] = dp[i-2] + dpm2 elif i == 0: pass else:...
p03160
s499056235
Wrong Answer
N=int(input()) H=list(map(int,input().split())) dp=[float('inf')]*N dp[0],dp[1]=0,H[1]-H[0] for i in range(2,N): dp[i]=min((dp[i-2]+abs(H[i]-H[i-2]),(dp[i-1]+abs(H[i]-H[i-1])))) print(dp[N-1])
p03160
s118988482
Wrong Answer
n = int(input()) h = list(map(int, input().split())) dp = [0]*(n+1) dp[0] = 0 for i in range(1, n): if i == 1: dp[i] = dp[i-1] + abs(h[i]-h[i-1]) else: dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-1])) print(dp[n-1])
p03160
s214542502
Wrong Answer
n = int(input()) h = list(map(int,input().split())) c = [0]*n c[1]=abs(h[1]-h[0]) for i in range(1,n): c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1])) print(c[n-1])
p03160
s100083305
Wrong Answer
N = int(input()) H = list(map(int, input().split())) INF = 10**4 + 1 minlist = [INF]*N minlist[0] = 0 for i in range(N-2): minlist_i = minlist[i] minlist[i+1] = min(minlist[i+1], minlist_i + abs(H[i] - H[i+1])) minlist[i+2] = min(minlist[i+2], minlist_i + abs(H[i] - H[i+2])) minlist[N-1] = min(minlist[N-1],...
p03160
s042655902
Wrong Answer
N, *h = map( int, open(0).read().split()) D = [0] + [ abs( h[1] - h[0])] k = [ abs( h[1] - h[0])] for i in range( 1, N - 1 ): k = min( D[ 0 ] + abs( h[ i + 1 ] - h[ i - 1 ]), D[ 1 ] + abs( h[ i + 1 ] - h[ i ])) D[ 0 ], D[ 1 ] = D[ 1 ], k print( k )
p03160
s512970773
Wrong Answer
N=int(input()) h=list(map(int,input().split())) DP=[0]*N DP[0]=0 DP[1]=h[1]-h[0]-DP[0] i=2 while i<N: DP[i]=min(abs(h[i]-h[i-1]-DP[i-1]),abs(h[i]-h[i-2]-DP[i-2])) i+=1 print(DP[-1])
p03160
s583070441
Wrong Answer
#DPまとめコンテストA問題より infinity=10**6 N = int(input()) h = list(map(int,input().split())) dp=[infinity]*N dp[0]=0 for i in range(N-1): dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i])) if i>=1: dp[i+1] = min(dp[i+1],dp[i-1]+abs(h[i+1]-h[i-1])) print(dp[N-1])
p03160
s487209090
Wrong Answer
# EDPC A Frog 1 N = int(input()) H = list(map(int,input().split())) cost = [0]*N cost[1] = abs(H[1]-H[0]) for i in range(2,N): cost[i] = min(cost[i-1]+abs(H[i]-H[i-1]),cost[i-2]+abs(H[i]-H[i-2])) print(cost) print(cost[N-1])
p03160
s311324335
Wrong Answer
def jumpCost(array): size = len(array) memo = [99999999999] * (size) memo[0] = 0 for i in range(size): j = i+1 while j < i + 2 + 1 and j < size: memo[j] = min(memo[j], memo[i] + abs(array[i] - array[j])) j += 1 return memo[size - 1] if __name__ == '__m...
p03160
s624405585
Wrong Answer
n = int(input()) h = list(map(int, input().split())) dp = [0] dp.append(abs(h[1]-h[0])) print(dp) if n > 2: for i in range(2,n): dp.append(min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1])) print(dp[-1])
p03160
s372308940
Wrong Answer
n = int(input()) H = list(map(int, input().split())) DP = [10 ** 5] * n DP[0] = 0 for i in range(1, n): DP[i] = min(DP[i], DP[i - 1] + abs(H[i] - H[i - 1])) if i > 1: DP[i] = min(DP[i], DP[i - 2] + abs(H[i] - H[i - 2])) print(DP[n - 1])
p03160
s123658552
Wrong Answer
n = int(input()) h = list(map(int, input().split())) f = [1 << 20] * n f[0] = 0 for i in range(0, n): if i >= 1: f[i] = min(f[i], f[i - 1] + abs(h[i] - h[i - 1])) if i >= 2: f[i] = min(f[i], f[i - 2] + abs(h[i] - h[i - 2])) print(f[n - 1])
p03160
s395254073
Wrong Answer
N = int(input()) h = list(map(int, input().split())) def chmin(a, b): min = a if a > b: min = b return min h_inf = 10 ** 5 dp = [h_inf] * N dp[0] = 0 for i in range(N-1): dp[i+1] = chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1])) if i+2 < N: dp[i+2] = chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2])) ...
p03160
s857404684
Wrong Answer
N=int(input()) H=list(map(int,input().split())) dplist=[0 for i in range(N)] dplist[0]=0 dplist[1]=abs(H[1]-H[0]) for i in range(2,N): dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i])) print(dplist)
p03160
s839787859
Wrong Answer
n = int(input()) h = [i for i in map(int, input().split())] DP = [0]*n DP[0] = 0 DP[1] = abs(h[1]-h[0]) for i in range(n-2): if abs(h[i+2]-h[i+1]) < abs(h[i+2]-h[i]): DP[i+2] = DP[i+1] + abs(h[i+2]-h[i+1]) else: DP[i+2] = DP[i] + abs(h[i+2]-h[i]) print(DP[-1])
p03160
s098583022
Wrong Answer
def func(arr): crr=[0 for i in range(len(arr))] crr[0]=arr[0] crr[1]=arr[1]-arr[0] for i in range(2,len(arr)): crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2]) print(crr[-1]) b=input() cr=list(map(int,input().split())) func(cr)
p03160
s554233470
Wrong Answer
n = int(input()) h = list(map(int,input().split())) dp = [99999999]*n dp[0]=0 dp[1]=h[1]-h[0] for i in range(2,n): dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) print(dp[n-1])
p03160
s062314655
Wrong Answer
import numpy as np N = int(input()) h = [0] + list(map(int, input().split())) dp = np.full(N+1, 10**9) dp[0] = 0 dp[1] = 0 for i in range(2, N+1): dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1])) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2])) print(dp[N])
p03160
s750560192
Wrong Answer
n = int(input()) h = list(map(int,input().split())) dp = [10**8]*n dp[0] = 0 dp[1] = h[1] - h[0] for i in range(1,n): dp[i] = min(dp[i],dp[i-1] + abs(h[i] - h[i-1])) if i >= 2: dp[i] = min(dp[i],dp[i-2] + abs(h[i] - h[i-2])) print(dp[-1])
p03160
s815288444
Wrong Answer
N=int(input()) S=list(map(int,input().split())) for i in range(100010): S.append(1000000000) DP=[100000000]*100010 DP[0]=0 for i in range(N): if DP[i+1]>DP[i]+abs(S[i+1]-S[i]): DP[i+1]=DP[i]+abs(S[i+1]-S[i]) if DP[i+2]>DP[i]+abs(S[i+2]-S[i]): DP[i+2]=DP[i]+abs(S[i+2]-S[i]) print(DP[N-1])...
p03160
s999333162
Wrong Answer
def chmin(a, b): if a > b: return b return a def main(): N = int(input()) hs = [i for i in map(int, input().split())] dp = [1e4+10]*100010 dp[0] = 0 for i in range(1, N): dp[i] = chmin(dp[i], dp[i-1] + abs(hs[i]-hs[i-1])) if i > 1: dp[i] = chmin(dp[i], dp[i-2] + abs(hs[i]-hs[i-2])) ...
p03160
s612047467
Wrong Answer
N = int(input()) h = list(map(int, input().split(" "))) dp = [1000000 for i in range(N)] dp[0] = 0 i = 0 for i in range(N-1): dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i]) if i + 2 < N: dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i]) print(dp[-1])
p03160
s032528399
Wrong Answer
n=int(input()) lis=list(map(int,input().split())) num=0 j=0 while(j<len(lis)-1): m=0 k=0 m=abs(lis[j]-lis[j+1]) if(j<len(lis)-2): k=abs(lis[j]-lis[j+2]) else: k=1000000 if(m<k): num=num+m j=j+1 else: num=num+k j=j+2 print(num)
p03160
s625523803
Wrong Answer
def chmin(target, index, value): if (target[index] > value): target[index] = value n = int(input()) h = [i for i in input().split(" ")] dp =[10000] * n dp[0] = 0 for i in range(1, n): chmin(dp, i, dp[i - 1] + (abs(int(h[i]) - int(h[i - 1])))) if i > 1: chmin(dp, i, dp[i - 2] + (abs(int(h[i...
p03160
s681816327
Wrong Answer
a = input() hs = [int(x) for x in input().split()] dp = [1000000000]* len(hs) if len(hs) == 1: print(hs[0]) exit() dp[0] = 0 dp[1] = abs(hs[1] - hs[0]) if len(hs) == 2: print(dp[1]) exit() for i in range(len(hs)-2): if i + 1 < len(hs): dp[i+1] = min(abs(hs[i+1]- hs[i]), dp[i+1]) if(i+2 < len(hs)...
p03160
s548553653
Wrong Answer
N = int(input()) h = list(map(int, input().split())) ans = [100000000] * N ans[0] = 0 for i in range(N-1): ans[i+1] = min(ans[i+1], ans[i] + abs(h[i] - h[i+1])) if i + 2 > N - 1: continue ans[i+2] = min(ans[i+2], ans[i] + abs(h[i] - h[i+2])) print(ans[-1])