# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261744 | cheeheng | Climbers (RMI18_climbers) | C++14 | 1096 ms | 5240 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;
int h[5005];
int h2[250005];
int main(){
int N;
scanf("%d", &N);
for(int i = 0; i < N; i ++){
scanf("%d", &h[i]);
}
int M = 1;
h2[0] = 0;
for(int i = 0; i < N-1; i ++){
if(h[i] < h[i+1]){
for(int j = h[i]+1; j <= h[i+1]; j ++){
h2[M++] = j;
}
}else if(h[i] > h[i+1]){
for(int j = h[i]-1; j >= h[i+1]; j --){
h2[M++] = j;
}
}
}
for(int i = 0; i < M; i ++){
printf("h2[%d]=%d\n", i, h2[i]);
}
long long ans = 0;
int A = 0;
int B = M-1;
while(A < B){
//printf("while loop: %d %d %lld\n", A, B, ans);
//if(ans > 100){break;}
if(h2[A+1] == h2[B-1]){
A ++;
B --;
ans ++;
continue;
}
if(h2[A-1] == h2[B-1]){
while(h2[A-1] == h2[B-1]){
A --;
B --;
ans ++;
}
}else{
while(h2[A+1] == h2[B+1]){
A ++;
B ++;
ans ++;
}
}
}
printf("%lld\n", ans);
return 0;
}
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... |