aboutsummaryrefslogtreecommitdiff
path: root/01_introductory_problems/increasing_array_1094.cpp
blob: 314c68621c06aa5600b806471af09484e5c08cb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <algorithm>
#include <iostream>

int main() {
	long long n, prev{0}, sum{0};
	std::cin >> n;
	while (std::cin >> n) {
		sum += std::max<long long>(0, prev - n);
		prev = std::max(prev, n);
	}
	std::cout << sum << std::endl;
}

Generated with cgit - Back to sebastiano.tronto.net