diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-07-06 19:08:08 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-07-06 19:08:08 +0200 |
| commit | 96254947699986c59f0dc63d69fd4b76bd3ed43e (patch) | |
| tree | 6c4dca945d7f7427c48be234d827fe4d33be02c5 /01_introductory_problems/increasing_array_1094.cpp | |
| download | cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.tar.gz cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.zip | |
Initial commit
Diffstat (limited to '01_introductory_problems/increasing_array_1094.cpp')
| -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 | } | ||
