-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIncreasing Array.cpp
More file actions
45 lines (43 loc) · 915 Bytes
/
Copy pathIncreasing Array.cpp
File metadata and controls
45 lines (43 loc) · 915 Bytes
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
43
44
45
//
// main.cpp
// CSES_4
//
// Created by Hea on 09/08/2022.
//
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
// insert code here...
unsigned long long n,sum=0,x;
unsigned long long j;
vector <unsigned long long> v;
cin >> n;
//cout << n << endl;
for(unsigned long long m=0;m<n;m++)
{
//cout << m << "k" << endl;
cin >> j;
v.push_back(j);
}
//cout << v.size() << endl;
for(unsigned long long k=1;k<v.size();k++)
{
//cout << v[k] << ' ' << v[k-1] << "---------" << endl;
x=0;
if(v[k]>v[k-1])
{
continue;
}
else
{
//cout << v[k-1] << ' ' << v[k] << endl;
x=v[k-1]-v[k];
v[k]+=x;
//cout << x << endl;
sum+=x;
}
}
cout << sum;
return 0;
}