From c922967b8b2ce6ec78effbc54ae0700c7af1e875 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Wed, 18 Dec 2024 10:56:22 -0700 Subject: 1094. increasing array --- introductory_problems/increasing_array.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 introductory_problems/increasing_array.cpp (limited to 'introductory_problems/increasing_array.cpp') diff --git a/introductory_problems/increasing_array.cpp b/introductory_problems/increasing_array.cpp new file mode 100644 index 0000000..8911474 --- /dev/null +++ b/introductory_problems/increasing_array.cpp @@ -0,0 +1,16 @@ +// 1094. Increasing Array +#include +using namespace std; + +int main() { + static int arr_size; + static long long arr, curr, cnt; + scanf("%d", &arr_size); + scanf("%lld", &curr); + for (int i = 1; i < arr_size; i++) { + scanf("%lld", &arr); + curr = max(curr, arr); + cnt += (curr - arr); + } + printf("%lld\n", cnt); +} -- cgit v1.2.3