forked from 790hanu/Annex-qr-code-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Increasing_arrays.txt
42 lines (42 loc) · 1.04 KB
/
Increasing_arrays.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//...AKASH KESHRI...//
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define MOD 1000000007
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
//=======================
void solve() {
ll n;
cin>>n;
ll sum=0;
vector<ll> a(n);
for(ll i=0;i<n;i++){
cin>>a[i];
}for(ll i=0;i<n-1;i++){
if(a[i]>a[i+1]){
sum+=abs(a[i]-a[i+1]);
a[i+1]=a[i];
}
}cout<<sum<<endl;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// int t;
// cin>>t;
// while(t--){
solve();
// }
return 0;
}