Skip to content

Commit 36e44af

Browse files
committed
1 parent cf2de03 commit 36e44af

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
N = int(input())
2+
ansList = []
3+
4+
for i in range(N):
5+
days = int(input())
6+
costs = list(map(int, input().split()))
7+
ans = 0
8+
9+
maxCost = -1
10+
11+
for j in range(len(costs) - 1, -1, -1):
12+
if maxCost > costs[j]:
13+
ans += maxCost - costs[j]
14+
else:
15+
maxCost = costs[j]
16+
17+
ansList.append(ans)
18+
19+
for i in range(len(ansList)):
20+
print(f"#{i + 1} {ansList[i]}")

0 commit comments

Comments
 (0)