problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p02578
s710198386
Accepted
import sys N = int(input()) A = list(map(int, input().split())) Sum = 0 for i in range(N-1): if A[i] > A[i+1]: Sum += A[i] - A[i+1] A[i+1] = A[i] print(Sum)
p02578
s535206861
Accepted
N = int(input()) A = list(map(int,input().split( ))) m = A[0] ans = 0 for Ai in A[1:]: if Ai <= m: ans += (m - Ai) else: m = Ai print(ans)
p02578
s818537483
Accepted
n = int(input()) arr = list(map(int, input().split())) cnt = 0 for i in range(1, n): ai = arr[i] ai_ = arr[i-1] if ai >= ai_: pass else: cnt += ai_ - ai arr[i] = ai_ print(cnt)
p02578
s699474009
Accepted
n=int(input()) a=list(map(int,input().split())) ans = 0 for i in range(n-1): if a[i] > a[i+1]: stand = a[i]-a[i+1] a[i+1] = a[i] ans += stand print(ans)
p02578
s141101190
Accepted
n=int(input()) li = list(map(int,input().split())) ans=0 for i in range(n-1): if li[i]<=li[i+1]: pass else: ans+=li[i]-li[i+1] li[i+1]=li[i] print(ans)
p02578
s264275568
Accepted
n=int(input()) a=list(map(int,input().split())) b=0 for i in range(n-1): if a[i]>a[i+1]: b+=a[i]-a[i+1] a[i+1]=a[i] print(b)
p02578
s424860429
Accepted
def solve(string): _, *a = map(int, string.split()) ans = step = 0 for a0, a1 in zip(a, a[1:]): step = max(0, a0 + step - a1) ans += step return str(ans) if __name__ == '__main__': import sys print(solve(sys.stdin.read().strip()))
p02578
s366393156
Accepted
#c n = int(input()) a = list(map(int, input().split())) i = 1 ans = 0 before = a[0] while i < len(a): if before > a[i]: ans += before - a[i] before = max(before,a[i]) i+=1 print(ans)
p02578
s878493940
Accepted
#C N=int(input()) A = list(map(int, input().split())) ans=0 a=A[0] for i in range(1,len(A)): if A[i]-A[i-1]<0: ans+=A[i-1]-A[i] A[i]=A[i-1] print(ans)
p02578
s145665813
Accepted
import sys n = int(input()) r = list(map(int,input().split())) ans = 0 for i in range(len(r)-1): if r[i]>r[i+1]: ans += r[i]-r[i+1] r[i+1] = r[i] print(ans)
p02578
s047002530
Accepted
n = int(input()) a = [int(s) for s in input().split()] t=a[0] total=0 for i in range(n): if t>a[i]: total=total+t-a[i] else: t=a[i] print(total)
p02578
s445818890
Accepted
n = int(input()) a = list(map(int, input().split())) sum = 0 max = 0 for i in a: if i >= max: max = i else: sum += max - i print(sum)
p02578
s075924098
Accepted
N = int(input()) A = list(map(int,input().split())) num_before = A[0] dai_sum = 0 for num in A: if num_before > num: dai_sum += num_before - num else: num_before = num print(dai_sum)
p02578
s413188723
Accepted
n = int(input()) a = list(map(int, input().split())) prev = a[0] dai = 0 for i in range(n-1): if a[i+1] >= prev: prev = a[i+1] else: dai += prev - a[i+1] print(dai)
p02578
s651897749
Accepted
import copy N = int(input()) A = list(map(int, input().split())) A2 = copy.copy(A) B = [A[0]] for i in range(N-1): if A[i+1] < A[i]: B.append(A[i]) A[i+1] = A[i] else: B.append(A[i+1]) ans = 0 for i in range(N): ans += B[i] -A2[i] print(ans)
p02578
s200002777
Accepted
import sys input = sys.stdin.buffer.readline n = int(input()) a = list(map(int,input().split())) res = 0 for i in range(1,n): if a[i] >= a[i-1]: continue res += a[i-1] - a[i] a[i] = a[i-1] print(res)
p02578
s151401815
Accepted
n = int(input()) arr = list(map(int,input().split())) ans = 0 for i in range(1,n): if arr[i]<arr[i-1]: ans += arr[i-1]-arr[i] arr[i] += arr[i-1]-arr[i] print(ans)
p02578
s766654180
Accepted
n = int(input()) a = [int(x) for x in input().split()] base = a[0] ans = 0; for i in range(1,n): if a[i] <= base: ans += base - a[i] else: base = a[i] print(ans)
p02578
s049019670
Accepted
N = int(input()) A = list(map(int,input().split())) ans = 0 for i in range(N-1): if A[i]>A[i+1]: ans += (A[i] - A[i+1]) A[i+1] = A[i] print(ans)
p02578
s968068014
Accepted
N = int(input()) A = [int(i) for i in input().split()] h = A[0] res = 0 #sum for i in range(N): if A[i] >= h: h = A[i] else: res += h - A[i] print(res)
p02578
s389348063
Accepted
n=int(input()) a_list=list(map(int,input().split())) b_list=[] for i in range(n-1): d=a_list[i]-a_list[i+1] if(d>=0): b_list.append(d) a_list[i+1]+=d ans=sum(b_list) print(ans)
p02578
s548463162
Accepted
n = int(input()) row = list(map(int,input().split())) a = row[0] b =0 fumi = 0 for i in row: b = i if a <= b: a = b next else: fumi += (a - b) a = max(a, b) print(fumi)
p02578
s763886731
Accepted
n = input() a = [int(i) for i in input().split()] maxer = a[0] sumer = 0 for i in a: if i <= maxer: sumer += maxer - i else: maxer = i print(sumer)
p02578
s863683692
Accepted
N = int(input()) A = list(map(int, input().split())) ans = 0 M = -1 for i in range(N): M = max([M, A[i]]) if A[i] < M: ans += M - A[i] print(ans)
p02578
s264526413
Accepted
N = int(input()) A = list(map(int, input().split())) sumF = 0 maxa = A[0] fumidai = 0 for i in range(N-1): if A[i] > A[i+1]: sumF += A[i] - A[i+1] A[i+1] = A[i] print(sumF)
p02578
s548578238
Accepted
N = int(input()) A = list(map(int,input().split())) keep = 0 cnt =0 x=0 for a in A: if keep > a: cnt += keep -a x = keep -a keep = a + x else: keep = a print(cnt)
p02578
s246024412
Accepted
import sys def main(): N = int(input()) A = list(map(int, input().split())) H = 0 max = A[0] for i in range(N-1): if max>A[i+1]: H = H + max - A[i+1] if max < A[i+1]: max = A[i+1] print(H) if __name__ == "__main__": main()
p02578
s277220923
Accepted
n = int(input()) a_list = list(map(int, input().split())) ans = 0 for i in range(1, n): diff = a_list[i - 1] - a_list[i] if diff > 0: a_list[i] += diff ans += diff print(ans)
p02578
s351519169
Accepted
n = int(input()) l = list(map(int,input().split())) h = 0 sum = 0 for i in range(n): if l[i] <= h: sum += h - l[i] else: h = l[i] print(sum)
p02578
s463046230
Accepted
def main(): N = int(input()) A = [int(c) for c in input().split()] m = A[0] ans = 0 for i, a in enumerate(A[1:]): m = max(m, a) if m > a: ans += m - a print(ans) if __name__ == "__main__": main()
p02578
s288630134
Accepted
n = int(input()) l = list(map(int,input().split())) p=l[0] s=0 for i in l[1:]: s+= max(0,p-i) p=max(p,i) print(s)
p02578
s925614358
Accepted
n = int(input()) a = list(map(int, input().strip().split())) ans = 0 for i in range(1, n): if(a[i-1] > a[i]): ans += abs(a[i-1]-a[i]) a[i] += abs(a[i-1]-a[i]) print(ans)
p02578
s022598433
Accepted
n = int(input()) A = list(map(int,input().split())) step = [0] for k,i in enumerate(A[1:]): if A[k] >= i: step.append(A[k] - i) A[k+1] = A[k+1] + A[k] - i print(sum(step))
p02578
s226099854
Accepted
import sys from collections import defaultdict, Counter, namedtuple, deque import itertools import functools import bisect import heapq import math import copy # from fractions import gcd MOD = 10 ** 9 + 7 # MOD = 998244353 # sys.setrecursionlimit(10**8) n = int(input()) A = list(map(int, input().split())) s = 0 for i in range(1, n): if A[i-1] > A[i]: s += A[i - 1] - A[i] A[i] += A[i-1] - A[i] print(s)
p02578
s521672211
Accepted
n = int(input()) a = [int(x) for x in input().split(" ")] s = [0] for x in range(1, n): stool = max(a[x - 1] - a[x], 0) s.append(stool) a[x] += stool print(sum(s))
p02578
s354154544
Accepted
from collections import Counter import sys sys.setrecursionlimit(10 ** 6) mod = 1000000007 inf = int(1e18) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] def inverse(a): return pow(a, -1, mod) def main(): n =int(input()) a = list(map(int, input().split())) x = a[0] ans = 0 for y in a[1:]: if x > y: ans += x - y x = max(x, y) print(ans) main()
p02578
s196740664
Accepted
N=int(input()) A=list(map(int,input().split())) ans=0 maxheight=A[0] for i in range(len(A)): ans+=max(maxheight-A[i],0) maxheight=max(maxheight,A[i]) print(ans)
p02578
s022715936
Accepted
n = int(input()) l = list(map(int,input().split())) ans,newm = 0,l[0] for i in l[1:]: if newm>i: ans += newm - i else: newm = i print(ans)
p02578
s599701203
Accepted
n = int(input()) A = list(map(int, input().split())) ans = 0 maxA = 0 for a in A: if a > maxA: maxA = a else: ans += (maxA - a) # print(maxA) print(ans)
p02578
s115008175
Accepted
n = int(input()) a = list(map(int, input().split())) sum=0 diff=0 for i in range(1,n): diff=a[i-1]-a[i] if diff>=0: sum+=diff a[i]+=diff print(sum)
p02578
s701922812
Accepted
N = int(input()) A = list(map(int, input().split())) ans = 0 l = A[0] for i in range(N-1): a = A[i+1] if a < l: ans += l - a else: l = a print(ans)
p02578
s443799388
Accepted
N = int(input()) A = list(map(int, input().split())) step = 0 for i in range(1, len(A)): if A[i-1] <= A[i]: continue else: step += (A[i-1] - A[i]) A[i] += (A[i-1] - A[i]) print(step)
p02578
s486874619
Accepted
n = int(input()) A = list(map(int,input().split())) now = A[0] ans = 0 for a in A[1:]: if now > a: ans += now - a else: now = a print(ans)
p02578
s550730716
Accepted
import math t = int(input()) a = list(map(int,input().split())) highest = a.index(max(a)) ans=0 for i in range(1,highest): if a[i]<a[i-1]: ans+= (a[i-1]-a[i]) a[i] = a[i-1] for i in range(highest+1,len(a)): if a[i]<a[i-1]: ans+=(a[i-1]-a[i]) a[i]=a[i-1] print(ans)
p02578
s499005789
Accepted
n = int(input()) a = list(map(int, input().split())) step = 0 for i in range(1, n): if a[i-1] > a[i]: step += a[i-1]-a[i] a[i] = a[i-1] print(step)
p02578
s359140967
Accepted
n = int(input()) a = list(map(int, input().split())) x = a[0] ans = 0 for i in range(1,n): if a[i] <= x: ans += x - a[i] else: x = a[i] print(ans)
p02578
s123792116
Accepted
n = int(input()) A = list(map(int,input().split())) ans = 0 t = 0 for e,(i , j) in enumerate(zip(A,A[1:])): if i + t > j : ans += t + i-j t= t + i-j else:t = 0 # print(t,ans) print(ans)
p02578
s035817074
Accepted
n=int(input()) alist=list(map(int, input().split())) ans=0 num=alist[0] for i in range(1,n): if alist[i]<num: ans+=(num-alist[i]) else: num=alist[i] print(ans)
p02578
s024645082
Accepted
N = int(input()) A = [int(i) for i in input().split()] count = 0 for i in range(N) : if i==0 : continue if A[i]<A[i-1] : count += abs(A[i]-A[i-1]) A[i] += abs(A[i]-A[i-1]) print(count)
p02578
s418514440
Accepted
N = int(input()) A = list(map(int,input().split())) max = 0 ans = 0 for i in range(N): if max <= A[i]: max = A[i] else: ans += (max-A[i]) print(ans)
p02578
s329763737
Accepted
N = int(input()) A = list(map(int, input().split())) max_ = 0 ans = 0 for a in A: max_ = max(a, max_) if a < max_: ans += (max_ - a) print(ans)
p02578
s120575223
Accepted
def main(): N = int(input()) A = list(map(int,input().split())) high = 0 ans = 0 for i in range(N): if A[i] < high: ans += (high - A[i]) else: high = A[i] print(ans) if __name__ == '__main__': main()
p02578
s841937595
Accepted
import math def resolve(): N=int(input()) A=list(map(int,input().split())) tmp=0 Max=0 for i in range(1,N): Max=max(Max,A[i-1]) tmp+=max(0, Max - A[i]) print(tmp) resolve()
p02578
s574362058
Accepted
##main####################################### ## INPUT #################################### N=input() A = list(map(int,list(input().split()))) ## PROCESSING ############################### max=0 ans=0 for n in A: if max<n : max=n if max>n : ans=ans + max-n ## OUTPUT ################################### #print("++++OUTPUT++++") #print(A) print(ans)
p02578
s252861152
Accepted
def main(): N = int(input()) A = list(map(int, input().split())) tallest = A[0] ans = 0 for height in A: if height < tallest: ans += tallest - height elif height > tallest: tallest = height print(ans) if __name__ == "__main__": main()
p02578
s363344148
Accepted
N = int(input()) A = list(map(int,input().split())) ans = 0 for i in range(len(A)-1): if A[i] > A[i+1]: ans += A[i] - A[i+1] A[i+1] = A[i] else: continue print(ans)
p02578
s984819267
Accepted
N = int(input()) data = input().split() sum = 0 for i in range(N-1) : if(int(data[i]) > int(data[i+1])) : sum += int(data[i]) - int(data[i+1]) data [i+1] = data[i] print(sum)
p02578
s704099373
Accepted
n = int(input()) l = list(map(int,input().split())) ans = 0 for i in range(n-1): if l[i+1]<l[i]: ans+= l[i]-l[i+1] l[i+1]=l[i] print(ans)
p02578
s789287845
Accepted
n = int(input()) a = list(map(int,input().split())) b = [0] for i in range(n-1): s = a[i+1] - (a[i] + b[i]) if s < 0: b.append(abs(s)) else: b.append(0) c = sum(b) print(c)
p02578
s656100238
Accepted
N = int(input()) tall = list(map(int, input().split())) step = [0]*N sum_step = 0 for i in range(0, N-1): if tall[i]+step[i] > tall[i+1]: step[i+1] = tall[i] - tall[i+1] + step[i] sum_step += step[i+1] print(sum_step)
p02578
s091330698
Accepted
n=int(input()) a=list(map(int, input().split())) ans=0 for i in range(1,n): if a[i]<a[i-1]: ans+=a[i-1]-a[i] a[i]=a[i-1] print(ans)
p02578
s462920112
Accepted
n=int(input()) count=0 l=list(map(int,input().split())) for i in range(n-1): if(l[i]-l[i+1]>0): count=count+(l[i]-l[i+1]) l[i+1]=l[i+1]+(l[i]-l[i+1]) print(count)
p02578
s612147024
Accepted
n = int(input()) a = list(map(int, input().split())) current = a[0] sum_ = 0 for aa in a: if current <= aa: current = aa else: sum_ += current - aa print(sum_)
p02578
s343777509
Accepted
N = int(input()) A = list(map(int, input().split())) height = A[0] cnt = 0 for a in A: if a < height: cnt += (height - a) else: height = a print(cnt)
p02578
s274538791
Accepted
n = int(input()) a_L = list(map(int,input().split())) if len(a_L) == 1: print(0) exit() ans = 0 for i in range(0,len(a_L)-1): if a_L[i] > a_L[i+1]: ans += abs(a_L[i+1] - a_L[i]) a_L[i+1] = a_L[i] if a_L[-2] > a_L[-1]: ans += abs(a_L[-1]-a_L[-2]) print(ans)
p02578
s391581010
Accepted
n = int(input()) *arr, = map(int, input().split()) mx = arr[0] i = 1 ans = 0 while i < n: if arr[i] < mx: ans += mx - arr[i] mx = max(mx, arr[i]) i += 1 print(ans)
p02578
s247746778
Accepted
N = input() A = list(map(int, input().split())) ans = 0 cmax = A[0] for a in A[1:]: if a < cmax: ans += cmax - a else: cmax = a print(ans)
p02578
s743351520
Accepted
N = int(input()) a = list(map(int,input().split())) ans = sum(a) for i in range(N-1): if a[i]>a[i+1]: a[i+1]=a[i] ans_1 = sum(a) print(ans_1-ans)
p02578
s769005869
Accepted
n = int(input()) a = list(map(int,input().split())) now = a[0] ans = 0 for i in range(n): if a[i] < now: ans += now - a[i] elif a[i] > now: now = a[i] print(ans)
p02578
s176515718
Accepted
N = int(input()) A = [int(i) for i in input().split()] humidais = [0] for i in range(N-1): humidais.append(max(A[i]+humidais[i]-A[i+1], 0)) print(sum(humidais))
p02578
s757771201
Accepted
n = int(input()) a = list(map(int,input().split())) s = 0 now = 0 for i in a: if i > now: now = i else: s += now - i print(s)
p02578
s347085522
Accepted
N = int(input()) A = list(map(int, input().split())) prevMax = A[0] ans = 0 for i in range(1, N): prevMax = max(A[i-1], prevMax) if A[i] < prevMax : ans += prevMax - A[i] print(ans)
p02578
s645989014
Accepted
n=int(input()) A=list(map(int,input().split())) ans=0 ma=A[0] for i in range(1,n): if ma<A[i]: ma=A[i] else: ans+=(ma-A[i]) print(ans)
p02578
s082982083
Accepted
N = int(input()) A = [int(x) for x in input().split()] c = 0 p = 0 for a in A: if p < a: p = a else: c += p - a p = max(p, a) print(c)
p02578
s364973045
Accepted
N = int(input()) high = list(map(int, input().split())) dai = [] est = high[0] for i in range(N): if est > high[i]: dai.append(est-high[i]) elif est <= high[i]: est = high[i] print(sum(dai))
p02578
s179776380
Accepted
N = int(input()) A = list(map(int, input().split())) lim = 0 ans = 0 for a in A: ans += max(0, lim - a) lim = max(lim, a) #print(lim, a, ans) print(ans)
p02578
s768171968
Accepted
N=int(input()) re=0 A=list(map(int,input().split())) co=A[0] for i in range(N-1): s=A[i+1]-co if s<0: re=re-s else: co=A[i+1] print(re)
p02578
s334942389
Accepted
# from pprint import pprint # import math # import collections n = int(input()) # n, k = map(int, input().split(' ')) a = list(map(int, input().split(' '))) now_high = a[0] fumidai = 0 for _a in a: if now_high > _a: fumidai += now_high - _a else: now_high = _a print(fumidai)
p02578
s849937214
Accepted
a=int(input()) a_list=list(map(int,input().split())) count=0 for i in range(a-1) : m=a_list[i] n=a_list[i+1] if m>n : a_list[i+1]=m count+=m-n print(count)
p02578
s803011394
Accepted
N = int(input()) sin_list = list(map(int, input().split())) max_height = 0 total_additional_height = 0 for sin in sin_list: if max_height == 0: max_height = sin else: if sin >= max_height: max_height = sin else: total_additional_height += (max_height - sin) print(total_additional_height)
p02578
s564664318
Accepted
N = int(input()) A = map(int, input().split()) ma = 0 ans = 0 for a in A: ans -= max(0, ma-a) ma = max(ma, a) print(-ans)
p02578
s704137604
Accepted
n=int(input()) a=list(map(int, input().split())) ans=0 flag=a[0] for i in range(len(a)): if a[i] < flag: ans+=flag-a[i] else: flag = a[i] print(ans)
p02578
s713600273
Accepted
N = int(input()) arr = list(map(int,input().split(" "))) res = 0 for i in range(1,N) : if arr[i] < arr[i-1]: res += arr[i-1]-arr[i] arr[i] = arr[i-1] print(res)
p02578
s548138529
Accepted
import sys cin = sys.stdin.readline n = int(cin()) height = cin().split() last, ans = 0, 0 for i in height: diff = last - int(i) if diff > 0: ans += diff continue last = int(i) print(ans)
p02578
s723797086
Accepted
# cook your dish here n=int(input()) ans=0 v=list(map(int,input().split())) for i in range(1,n): if v[i]<v[i-1]: ans+=(v[i-1]-v[i]) v[i]=v[i-1] print(ans)
p02578
s708179754
Accepted
N = int(input()) A = list(map(int,input().split())) ans = 0 max_num = A[0] for i in range(1,N): ans += max(max_num - A[i],0) max_num = max(A[i],max_num) print(ans)
p02578
s980420400
Accepted
n = int(input()) a = list(map(int, input().split())) max_a_list = [0]*n max_a_list[0] = a[0] for i in range(1,n): max_a_list[i] = max(max_a_list[i - 1],a[i]) sum_ = 0 for i in range(n): if max_a_list[i] > a[i]: sum_ += max_a_list[i] - a[i] print(sum_)
p02578
s127357160
Accepted
n = int(input()) a = list(map(int,input().split())) ans = 0 for i in range(1,n): if a[i-1] > a[i]: ans += a[i-1]-a[i] a[i] += a[i-1]-a[i] print(ans)
p02578
s240166486
Accepted
N = int(input()) A = list(map(int,input().split())) humidai = 0 for i in range(1,N): if A[i-1] > A[i]: humidai_plus = (A[i-1] - A[i]) A[i] += humidai_plus humidai += humidai_plus print(humidai)
p02578
s013386192
Accepted
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) H = 0 ans = 0 for a in A: if H > a: ans += H - a else: H = a print(ans) if __name__ == '__main__': main()
p02578
s880412410
Accepted
N=int(input()) A=list(map(int,input().split())) h=0 for i in range(1,N): a=A[i]-A[i-1] if a<0: h-=a A[i]-=a print(h)
p02578
s726323639
Accepted
N = int(input()) A = list(map(int, input().split())) before = 0 d = [0] * N for i in range(N): if i == 0: before = i continue if (A[before] + d[before]) > A[i]: d[i] = (A[before] + d[before]) - A[i] before = i else: before = i print(sum(d))
p02578
s985706121
Accepted
N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(1, N): d = A[i - 1] - A[i] if d > 0: ans += d A[i] += d print(ans)
p02578
s600491580
Accepted
from collections import defaultdict from collections import deque from collections import Counter import math def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() n = readInt() a = readInts() ans = 0 if n==1: print(ans) exit() for i in range(1,len(a)): t = max(a[i],a[i-1]) ans += max(0, t-a[i]) a[i] = t print(ans)
p02578
s415430853
Accepted
n=int(input()) ppl=(input().split()) answer=0 if n==1: print(0) for x in range(0,n-1): ppl[x]=int(ppl[x]) ppl[x+1]=int(ppl[x+1]) if ppl[x]>ppl[x+1]: answer+=ppl[x]-ppl[x+1] ppl[x+1]=ppl[x] if(n!=1): print(answer)
p02578
s777731538
Accepted
# -*- coding: utf-8 -*- n = int(input()) a = list(map(int, input().split())) l = [] for i in range(len(a) - 1): if a[i + 1] < a[i]: l.append(a[i]-a[i + 1]) a[i + 1] = a[i] print(sum(l))
p02578
s459409002
Accepted
N = int(input()) A = list(map(int,input().split())) B = [0] * N ans = 0 for i in range (N): if i == 0: B[0] = A[0] else: if B[i-1] > A[i]: B[i] = B[i-1] ans = ans + B[i-1] - A[i] else: B[i] = A[i] ans = ans print (ans)
p02578
s018451437
Accepted
N = int(input()) A = list(map(int, input().split())) h = 0 tot = 0 for a in A: tot += max(h-a, 0) h = max(h, a) print(tot)
p02578
s712574004
Accepted
N = int(input()) A = list(map(int, input().split())) cur_tallest = A[0] res = 0 for a in A: if a <= cur_tallest: res += cur_tallest - a else: cur_tallest = a print(res)
p02578
s395062367
Accepted
n=int(input()) a=list(map(int,input().split())) ans=0 for i in range(1,n): if a[i-1]>a[i]: # print("i=",i) ans+=a[i-1]-a[i] a[i]+=a[i-1]-a[i] print(ans)