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 1788. On the Benefits of Umbrellas

#WA3 need test case
Posted by jim 5 Jul 2018 08:44
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int i,j,k,l,ii;
    int m,n;
    int girls[101];
    int boys[101];
    int count = 0;
    int upsets = 0, girlUpsets = 0, boyUpsets = 0, currentUpsets = 0;
    int happyGirls = 0;
    int chooseGirl = 0, chooseBoy = 0;

    for (i = 0; i <= 100; i ++)
    {
        girls[i] = 0;
        boys[i] = 0;
    }

    cin >> n >> m; //n girls m boys
    for (i = 1; i <= n; i ++)
    {
        cin >> girls[i];
    }
    for (j = 1; j <= m; j ++)
    {
        cin >> boys[j];
    }

    count = min (m, n);
    //计算无配对upset值
    for (i = 1; i <= n; i ++)
        upsets += girls[i];


    happyGirls = 0;


    for (i = 1; i <= count; i ++)

    {
        for (j = 1; j <= n; j ++)
            for ( k = 1; k <= m; k ++)
            {
                girlUpsets = 0;
                boyUpsets = 0;
                //计算girl upset值
                for (l = 1; l <= n; l ++)
                {
                    if (l != j)
                    {
                        girlUpsets += girls[l];
                    }
                }


                //计算boy upset值
                for (l = 1; l <= m; l ++)
                {
                    if (l != k)
                        boyUpsets += boys[l] * (happyGirls + 1);
                    //cout << "werqe: " << boys[l] << '\t' << boyUpsets << endl;
                }


                currentUpsets = girlUpsets + boyUpsets;
                if (currentUpsets < upsets)
                {
                    upsets = currentUpsets;
                    chooseGirl = j;
                    chooseBoy = k;
                }

            }

        if (chooseBoy != 0  && chooseGirl != 0)
        {
            happyGirls ++;

            //删除第chooseGirl个girl
            for (ii = chooseGirl; ii <= n - 1; ii ++)
               girls[ii] = girls[ii + 1];
            n --;

            //删除第chooseBoy个boy
            for (ii = chooseBoy; ii <= m - 1; ii ++)
                boys[ii] = boys[ii + 1];
            m --;
        }

    }
    cout << upsets << endl;
    return 0;
}
Re: #WA3 need test case
Posted by Pavel 15 Jun 2021 03:30
try
1 1
1
1