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 1152. False Mirrors

Help me pleaseeee!(
Posted by гоша 20 Aug 2009 14:00
I have WA3. May be I don't understand this problem.
#include <stdio.h>

int main()
{
    int n,a[20],i,s=0,rez=0;
    scanf("%i",&n);
    for (i=0; i<n; i++)
    {
        scanf("%i",&a[i]);
        s=s+a[i];
    }

    /*for (i=0; i<n; i++)
        printf("%i",a[i]);*/

    int maxs,maxi,j,sdop,k;
    bool ok=true;

    while (ok)
    {
        maxs=0;

    for (i=0; i<n; i++)
    {
        sdop=0;
        for (j=i; j<=i+2; j++)
        {
            if (j>n-1) sdop=sdop+a[j%n];
            else sdop=sdop+a[j];
        }
        if (sdop>maxs)
        {
            maxs=sdop;
            maxi=i;
        }
    }

    s=s-maxs;
    rez=rez+s;

    int d1,d2,d3;
    d1=maxi;
    if (maxi+1>n-1) d2=(maxi+1)%n;
    else d2=maxi+1;
    if (maxi+2>n-1) d3=(maxi+2)%n;
    else d3=maxi+2;

    a[d1]=0;
    a[d2]=0;
    a[d3]=0;

    ok=false;
    k=0;
    while (!ok && k<n)
    {
        if (a[k]!=0) ok=true;
        else k++;
    }

    }
    printf("%i",rez);

    return 0;
}