SRM478 Div2 Easy(250) KiwiJuiceEasy

KiwiJuiceEasy

#include <vector>

using namespace std;

class KiwiJuiceEasy
{
public:
    vector <int> thePouring( vector <int> capacities, vector <int> bottles, vector <int> fromId, vector <int> toId );
};

vector <int> KiwiJuiceEasy::thePouring( vector <int> capacities, vector <int> bottles, vector <int> fromId, vector <int> toId )
{
    int M = fromId.size();

    for ( int i=0; i<M; i++ )
    {
        int f = fromId[i];
        int t = toId[i];
        int x = min( bottles[f], capacities[t]-bottles[t] );
        bottles[f] -= x;
        bottles[t] += x;
    }

    return bottles;
}