Hello,
I've been given a task to write a program which could output the biggest amount of soda that the guests of a party could drink. 'n' is the amount of boys as well as girls. Every girl needs to be allowed to drink equally as much as every other girl, every boy as much as every other boy. Men shall drink twice as much as women.
I have already came up with an idea as to how it should be done, but the code is not finished.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
using namespace std;
int main()
{
party:
int n;
cin>>n;
int capacity;
cin>>capacity;
int glass = 2*n;
int boys = n;
int girls = n;
int glass_quantity[glass];
int capture = 0;
int acknowledge = -1;
double boundary;
for(int i = 1; i < sizeof(glass_quantity); i++)
{
if(capture>capacity)
{
cout<<"Too much liquid has been proposed for a glass."<<endl;
goto party;
}
if(capacity==capture) break;
cin>>glass_quantity[i];
capture+=glass_quantity[i];
acknowledge++; //counts the amount of used glasses
}
int boys_maximum = 0;
int girls_maximum = 0;
bool enter = true;
for(; acknowledge > 0; acknowledge--)
{
if(boys_maximum!=(capture/3)*2 && enter)
{
boys_maximum += glass_quantity[acknowledge];
boundary +=glass_quantity[acknowledge];
enter = false; //Every empty glass shall not be counted twice
}
if(girls_maximum!=capture/3 && enter)
{
girls_maximum += glass_quantity[acknowledge];
boundary +=glass_quantity[acknowledge];
}
enter = true;
}
cout<<boundary;
}
|
It is said that for n = 2, capacity = 4, glass_quantity[0] = 1, glass_quantity[1] = 1, glass_quantity[2] = 1, glass_quantity[3] = 1 the result should be 3. For n = 1, capacity = 5, glass_quantity[0] = 2, glass_quantity[1] = 3 the result should be 4,5.
I have no idea how do I make the program realise, for example, how much soda will not be allowed for the guests. Please, give me only some clues rather than answers.