berthin/problemas_programacion — Issue #1: 4788_la
Author: berthin
Created: 2012-02-04 21:47:29+00:00
State: open

//AC

#include
#include
#include
#include
#include

#define inf (1<<30)
#define MAX 100

using namespace std;

int N, Ne[MAX], So[MAX];
vector < int > G[MAX];
bool visit[MAX];

bool cmp(pair < int, int > a, pair < int, int > b){
return (a.second >= b.second);
}

pair < int , int > getCost(int node){
if(visit[node]) return make_pair(0, 0);
visit[node] = true;
pair < int, int > V[G[node].size()];
for(int i=0; i V[i].first){
lastSo -= (V[i].first - V[i].second);
}else{
acumNe += (V[i].first - lastSo);
lastSo = V[i].second;
}
}
return make_pair(acumNe, lastSo);
}

int getMinCost(){
int minCost = (1 << 30);
for(int node=0; node