Submission #510117

# Submission time Handle Problem Language Result Execution time Memory
510117 2022-01-14T17:48:14 Z M_sawas_ Nizin (COCI16_nizin) C++17
0 / 100
1000 ms 9596 KB
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
ll n,a[1000007],ans,l,r;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    l=1,r=n;
    while(l<r){
        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[r]+a[r-1]==a[l]){
                ans++,l++,r-=2;
            }
            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 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Execution timed out 1089 ms 204 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1048 ms 1000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1042 ms 3652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1016 ms 7748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 9596 KB Time limit exceeded
2 Halted 0 ms 0 KB -