# BZOJ 1877: [SDOI2009]晨跑

/*
BZOJ 1877: [SDOI2009]晨跑

拆点 + 费用流

*/
#include <cstdio>
#include <iostream>
#define rg register
inline void read (int &n) {
rg char c = getchar ();
for (n = 0; !isdigit (c); c = getchar ());
for (; isdigit (c); n = n * 10 + c - '0', c = getchar ());
}
int S, T;
#define Max 7000
#define INF 1e9
namespace net {
const int MaxE = 2000000;
int _n[MaxE], _v[MaxE], list[Max], _f[MaxE], _c[MaxE], EC = 1, d[Max], q[MaxE], pre[Max];
bool is[Max]; int c[Max];
inline void In (int u, int v, int f, int c) {
_v[++ EC] = v, _n[EC] = list[u], list[u] = EC, _f[EC] = f, _c[EC] = c;
_v[++ EC] = u, _n[EC] = list[v], list[v] = EC, _f[EC] = 0, _c[EC] = -c;
}

bool Bfs () {
int h = 1, t = 1; q[t] = S; rg int i, n;
for (i = 0; i <= T; ++ i) d[i] = INF, is[i] = false;
for (d[S] = 0, c[S] = INF, pre[S] = 0; h <= t; ++ h)
for (n = q[h], is[n] = false, i = list[n]; i; i = _n[i])
if (d[_v[i]] > d[n] + _c[i] && _f[i]) {
d[_v[i]] = d[n] + _c[i], pre[_v[i]] = i, c[_v[i]] = std :: min (c[n], _f[i]);
if (!is[_v[i]]) q[++ t] = _v[i], is[_v[i]] = true;
}
return d[T] < INF;
}
int Do () {
int res = 0, p = 0; rg int i;
for (int x; Bfs (); ++ p) {
for (x = c[T], i = T; i != S; i = _v[pre[i] ^ 1])
_f[pre[i]] -= x, _f[pre[i] ^ 1] += x;
res += d[T] * x;
}
printf ("%d %d", p, res);
}
}
int main (int argc, char *argv[]) {
}