답안 #261703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261703 2020-08-12T02:17:10 Z dantoh000 Climbers (RMI18_climbers) C++14
5 / 100
2 ms 384 KB
#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]);
    }
    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

climbers.cpp: In function 'int main()':
climbers.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
climbers.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Incorrect 1 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Incorrect 1 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 2 ms 384 KB Output isn't correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Incorrect 1 ms 384 KB Output isn't correct
10 Incorrect 1 ms 384 KB Output isn't correct