# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261707 | dantoh000 | Climbers (RMI18_climbers) | C++14 | 2 ms | 384 KiB |
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>
using namespace std;
typedef long long ll;
int n;
int a[5005];
int main(){
scanf("%d",&n);
for (int i = 0; i < n; i++){
scanf("%d",&a[i]);
}
printf("NO\n");
return 0;
int l = 1, r = n-2;
int pos = 0;
ll ans = 0;
while (l < r){
//printf("%d %d\n",l,r);
if (a[l] < a[r]){
ans += abs(pos-a[l]);
pos = a[l];
l++;
}
else{
ans += abs(pos-a[r]);
pos = a[r];
r--;
}
}
ans += abs(pos-a[l]);
printf("%lld",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |