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

what is my problem on c++?
Posted by nick nikuradze 8 May 2016 01:23
This is my code.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n,a,k=0;
    cin>>n;
    vector <int> v;
    vector <int> sum;
    vector <int> index;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    for(int i=1; i<n-1; i++)
    {
        sum.push_back(v[i-1]+v[i]+v[i+1]);
        index.push_back(i);
    }
    int max=sum[0];
    for(int i=1; i<n; i++)
    {
        if(sum[i]>max) {max=sum[i]; k=i;}
    }
    cout<<max<<" "<<index[k]+1;
    system("pause");
    return 0;
}
Re: what is my problem on c++?
Posted by Radu Tache 29 Jan 2019 02:16
If you look carefully, you don't get n sums and indexes, but actually n-2 sums and indexes.