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