#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin>>n;
vector<int>a(n);
int maxi=0,sum=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
if(i>0)
{
sum+=abs(a[i]-a[i-1]);
maxi=max(maxi,abs(a[i]-a[i-1]));
}
}
cout<<sum-maxi<<endl;
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |