#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
int diffarr[n];
diffarr[0]=arr[0];
for (int i = 1; i < n; i++){
diffarr[i] = arr[i] - arr[i - 1];
}
int sum=0;
for (int i=0;i<n;++i){
if (diffarr[i]>0){
sum+=diffarr[i];
}
}
cout << sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |