This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |