summaryrefslogtreecommitdiff
path: root/introductory_problems/increasing_array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'introductory_problems/increasing_array.cpp')
-rw-r--r--introductory_problems/increasing_array.cpp16
1 files changed, 16 insertions, 0 deletions
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 <bits/stdc++.h>
+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);
+}