답안 #201179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201179 2020-02-09T15:42:53 Z SamAnd Nizin (COCI16_nizin) C++17
100 / 100
124 ms 6416 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;

int n;
int a[N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
    }
    int s = 0;
    int l = 0, r = n + 1;
    long long suml = 0, sumr = 0;
    while (1)
    {
        if (l > r)
            break;
        if (l == r)
        {
            ++s;
            break;
        }
        if (suml < sumr)
        {
            ++l;
            suml += a[l];
        }
        else if (suml > sumr)
        {
            --r;
            sumr += a[r];
        }
        else
        {
            s += 2;
            ++l;
            --r;
            suml += a[l];
            sumr += a[r];
        }
    }
    s -= 2;
    printf("%d\n", n - s);
    return 0;
}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
nizin.cpp:13: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 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 456 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 7 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 760 KB Output is correct
2 Correct 16 ms 888 KB Output is correct
3 Correct 17 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 2428 KB Output is correct
2 Correct 53 ms 2820 KB Output is correct
3 Correct 60 ms 3252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 4856 KB Output is correct
2 Correct 95 ms 5120 KB Output is correct
3 Correct 107 ms 5624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 6136 KB Output is correct
2 Correct 117 ms 6416 KB Output is correct
3 Correct 121 ms 6240 KB Output is correct