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

Help, WA#6
Posted by ellozoid 20 Oct 2013 00:08
#include <iostream>

using namespace std;

int main()
{
    int n, i, j;
    cin >> n;
    long *a = new long[n];
    long *b = new long[n];
    long *c = new long[n];
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i <= n - 3; i++){
        b[i] = a[i] + a[i + 1] + a[i + 2];
        c[i] = i + 2;
    }
    for (j = 0; j <= n; j++)
    for (i = j+1; i <= n; i++)
    if (b[i] == b[j]){
        c[i] = c[j];
    }
    long max = b[0];
    long imax = c[0];
    for (i = 0; i <= n - 4; i++)
    if (b[i] < b[i + 1]){
        max = b[i + 1];
        imax = c[i + 1];
    }
    cout << max << ' ' << imax << endl;
}

Edited by author 20.10.2013 00:12

Edited by author 20.10.2013 00:12