답안 #95558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95558 2019-02-02T05:25:33 Z oolimry Nizin (COCI16_nizin) C++14
100 / 100
86 ms 10232 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    //freopen("i.txt","r",stdin);
    scanf("%d",&n);

    long long arr[n];

    for(int i = 0;i < n;i++){
        scanf("%lld",&arr[i]);
    }

    int lindex = 0;
    long long lsum = arr[0];
    int rindex = n-1;
    long long rsum = arr[n-1];
    int steps = 0;
    while(lindex < rindex){
            //printf("%d %d\n",lindex,rindex);
        if(lsum == rsum){
            lindex++;
            rindex--;
            rsum = arr[rindex];
            lsum = arr[lindex];
        }
        else if(lsum > rsum){
            rindex--;
            rsum += arr[rindex];
            steps++;
        }
        else{
            lindex++;
            lsum += arr[lindex];
            steps++;
        }
    }
    printf("%d",steps);
    for(int i = 0;i < n;i++){
        //printf("%lld ",arr[i]);
    }
    return 0;
}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
nizin.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1144 KB Output is correct
2 Correct 10 ms 1272 KB Output is correct
3 Correct 10 ms 1276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 3704 KB Output is correct
2 Correct 37 ms 4444 KB Output is correct
3 Correct 44 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 7800 KB Output is correct
2 Correct 69 ms 8192 KB Output is correct
3 Correct 82 ms 9212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 9976 KB Output is correct
2 Correct 86 ms 10232 KB Output is correct
3 Correct 86 ms 10108 KB Output is correct