code/Solution.hpp
// Determine if the solution is valid, which is 
// the allocated demand of a facility is no more than its capicity
// <Param>
//      vector<int> &capicity: capicity of facilities
//      vector<int> &demand: demand of customers
// </Param>
// <Return>
//		bool: true for valid, otherwise false
// </Return>
Determine if the solution is valid, which is
the allocated demand of a facility is no more than its capicity

vector &capicity: capicity of facilities
vector &demand: demand of customers


bool: true for valid, otherwise false

Determine if the solution is valid which is the allocated demand of a facility is no more than its capicity vector &capicity : capicity of facilities vector &demand : demand of customers bool : true for valid otherwise false
bool Solution::isValid(vector<int> &capicity, vector<int> &demand) {
    int size = capicity.size();
    for (int i = 0; i < size; ++i) {
    	this->serving[i] = 0;
	}
    size = this->allocate.size();
    for (int i = 0; i < size; ++i) {
        this->serving[this->allocate[i]-1] += demand[i];
    }
	size = capicity.size();
    for (int i = 0; i < size; ++i) {
        if (this->serving[i] > capicity[i]) {
            return false;
        }
    }
    return true;
}
bool Solution :: isValid ( vector < int > & capicity , vector < int > & demand ) { int size = capicity . size ( ) ; for ( int i = 0 ; i < size ; ++ i ) { this -> serving [ i ] = 0 ; } size = this -> allocate . size ( ) ; for ( int i = 0 ; i < size ; ++ i ) { this -> serving [ this -> allocate [ i ] - 1 ] += demand [ i ] ; } size = capicity . size ( ) ; for ( int i = 0 ; i < size ; ++ i ) { if ( this -> serving [ i ] > capicity [ i ] ) { return false ; } } return true ; }
Determine if the solution is valid, which is
the allocated demand of a facility is no more than its capicity
<Param>
vector<int> &capicity: capicity of facilities
vector<int> &demand: demand of customers
</Param>
<Return>
bool: true for valid, otherwise false
</Return>
Determine if the solution is valid which is the allocated demand of a facility is no more than its capicity <Param > vector<int > &capicity : capicity of facilities vector<int > &demand : demand of customers < / Param > <Return > bool : true for valid otherwise false < / Return >