ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1910. Titan Ruins: Hidden Entrance

WA#20
Posted by Paulinho 30 Nov 2014 23:26
#include <iostream>
using namespace std;
void main()
{
    int n;
    int a[998];
    cin>>n;
    int i;
    int s=0;
    int smax=0;
    int imid=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n-2;i++)
    {
        s=a[i]+a[i+1]+a[i+2];
        if(s>smax)
        {
            smax=s;
            imid=i+2;
        }
    }
    cout<<smax<<" ";
    cout<<imid;
}

What did i do wrong ?
Re: WA#20
Posted by Neeraj Kumar 27 Dec 2014 12:33
why have you taken array of size 998? make it 1000.