#include <bits/stdc++.h>
#define f first
#define S second
#define pb push_back
#define msk(x , y) ((x >> y) & 1)
#define all(x) x.begin() , x.end()
using namespace std;
typedef long long int ll;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
const int dx[] = {-1,-1,1,1,2,-2,2,-2};
const int dy[] = {-2,2,2,-2,1,1,-1,-1};
ll n , a[N] , p[N] , s[N];
void solve(){
cin >> n ;
ll ans = 0, pos = 0 , mx = 0 ;
for(int i = 1 ; i <= n; i++){
cin >> a[i];
if(n != i) ans += abs(a[i] - a[i - 1]);
}
cout << ans << "\n";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int test=1;
// cin >> test ;
for(int i=1;i<=test;i++){
// cout << "Case " << i << ": ";
solve();
}
}
Compilation message
climbers.cpp: In function 'void solve()':
climbers.cpp:18:14: warning: unused variable 'pos' [-Wunused-variable]
18 | ll ans = 0, pos = 0 , mx = 0 ;
| ^~~
climbers.cpp:18:24: warning: unused variable 'mx' [-Wunused-variable]
18 | ll ans = 0, pos = 0 , mx = 0 ;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
2516 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |