# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
261744 | cheeheng | Climbers (RMI18_climbers) | C++14 | 1096 ms | 5240 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |