diff options
Diffstat (limited to '')
| -rw-r--r-- | 01_introductory_problems/increasing_array_1094.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/01_introductory_problems/increasing_array_1094.cpp b/01_introductory_problems/increasing_array_1094.cpp new file mode 100644 index 0000000..314c686 --- /dev/null +++ b/01_introductory_problems/increasing_array_1094.cpp | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #include <algorithm> | ||
| 2 | #include <iostream> | ||
| 3 | |||
| 4 | int main() { | ||
| 5 | long long n, prev{0}, sum{0}; | ||
| 6 | std::cin >> n; | ||
| 7 | while (std::cin >> n) { | ||
| 8 | sum += std::max<long long>(0, prev - n); | ||
| 9 | prev = std::max(prev, n); | ||
| 10 | } | ||
| 11 | std::cout << sum << std::endl; | ||
| 12 | } | ||
