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 1167. Bicolored Horses

I need help
Posted by Mihran Hovsepyan {2 kurs of <RAU>} 12 Oct 2008 22:57
HI!
I tried solve this problem, but I always got WA1.
I can't find my mistake


# include <iostream>
using namespace std;
main ()
{
    char a;
    int min,hamar;
    int n,k;
    int i;
    int w[500]={0};
    int b[500]={0};
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a;
        if(a=='1')
            b[i]=1;
        else
            w[i]=1;
    }
    int ans=0;
    while(n!=k)
    {
        min=62500;
        for(i=0;i<n-1;i++)
            if(min>w[i]*b[i+1]+w[i+1]*b[i])
            {
                min=w[i]*b[i+1]+w[i+1]*b[i];
                hamar=i;
            }
        w[hamar]+=w[hamar+1];
        b[hamar]+=b[hamar+1];
        for(i=hamar+1;i<n;i++)
        {
            w[i]=w[i+1];
            b[i]=b[i+1];
        }
        n--;
        ans+=min;
    }
    cout<<ans;
    return 0;
}

Edited by author 15.12.2008 00:35
Re: To Administrators.
Posted by Nick J 13 Oct 2008 20:01
I could help you but I'm not Administrator.
Re: To Administrators.
Posted by Mihran Hovsepyan {2 kurs of <RAU>} 17 Oct 2008 22:27
If you can help me to find my mistake, then mail me to mihran91@mail.ru

Edited by author 22.10.2008 22:11