Submission #510221

# Submission time Handle Problem Language Result Execution time Memory
510221 2022-01-14T19:56:31 Z M_sawas_ Nizin (COCI16_nizin) C++17
0 / 100
48 ms 7936 KB
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll n,a[1000007],ans,l,r;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    l=1,r=n;
    for(int i=0;i<n&&l<r;i++){
        if(a[l]==a[r]){
            l++,r--;
        }
        else if(a[l]<a[r]){
            if(a[l]+a[l+1]==a[r]){
                ans++;l+=2;r--;
            }
            else if(a[l]+a[l+1]==a[r]+a[r-1]){
                ans+=2;l+=2;r-=2;
            }
        }
        else if(a[l]>a[r]){
            if(a[r]+a[r-1]==a[l]){
                ans++;r-=2;l++;
            }
            else if(a[l]+a[l+1]==a[r]+a[r-1]){
                ans+=2;l+=2;r-=2;
            }
        }
    }
    cout<<ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 3024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 6196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 7936 KB Output isn't correct
2 Halted 0 ms 0 KB -