Submission #40886

# Submission time Handle Problem Language Result Execution time Memory
40886 2018-02-09T18:01:49 Z XmtosX Nizin (COCI16_nizin) C++14
100 / 100
255 ms 23008 KB
#include <bits/stdc++.h>
using namespace std;
int n,ans;
long long a[1000006];
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%I64d",&a[i]);
    long long l=0,r=0;
    for (int i=0,j=n-1;i<j;)
    {
        if (l+a[i]==r+a[j])
        {
            l=r=0;
            i++;
            j--;
        }
        else if (l+a[i]<r+a[j])
        {
            l+=a[i];
            i++;
            ans++;
        }
        else
        {
            r+=a[j];
            j--;
            ans++;
        }
    }
    cout <<ans;
    return 0;
}

Compilation message

nizin.cpp: In function 'int main()':
nizin.cpp:9:28: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%I64d",&a[i]);
                            ^
nizin.cpp:7:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
nizin.cpp:9:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%I64d",&a[i]);
                             ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 624 KB Output is correct
3 Correct 1 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 736 KB Output is correct
2 Correct 1 ms 740 KB Output is correct
3 Correct 1 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 2 ms 772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 772 KB Output is correct
2 Correct 2 ms 784 KB Output is correct
3 Correct 2 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1560 KB Output is correct
2 Correct 26 ms 1848 KB Output is correct
3 Correct 27 ms 2068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 4720 KB Output is correct
2 Correct 108 ms 6256 KB Output is correct
3 Correct 127 ms 7940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 192 ms 11496 KB Output is correct
2 Correct 203 ms 13616 KB Output is correct
3 Correct 227 ms 16144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 248 ms 18884 KB Output is correct
2 Correct 255 ms 20956 KB Output is correct
3 Correct 255 ms 23008 KB Output is correct