LL calc(int M) { memset(ok, false, sizeof ok); for (int j = 0; j < n; ++j) if (g[j].second <= M) ok[j] = true; LL ret = 0; mf.init(); mf.s = n + m + 1; mf.t = n + m + 2; for (int j = 0; j < m; ++j) { bool flg = true; for (int k = 0; k < (int)f[j].size(); ++k) if (!ok[f[j][k]]) { flg = false; break; } if (flg) { ret += pro[j]; mf.addEdge(mf.s, j, pro[j]); for (int k = 0; k < (int)f[j].size(); ++k) mf.addEdge(j, m + f[j][k], INF); } } for (int j = m; j < n + m; ++j) if (ok[j-m]) mf.addEdge(j, mf.t, g[j-m].first); return ret - mf.maxFlow(); }
bool check(double lamda) { double ans; for(int i = 0; i < M; ++i) { mf.buf[i].c -= lamda; if(mf.buf[i].c < 0) ans += mf.buf[i].c; } ans += mf.maxFlow(1, N); for(int i = 0; i < M; ++i) mf.buf[i].c += lamda; return ans < 0; }
int main() { while( scanf( "%d%d%d%d", &N, &S, &T, &M ) != EOF ) { build(); printf( "%d\n", mf.maxFlow( N, N + 1 ) ); } }
int main() { while( cin >> N >> S >> T >> M ) { build(); cout << mf.maxFlow( N, N + 1 )<< endl; } }
bool check( int flow ) { for( int i = st; i < ed; ++i ) mf.buf[i].c = flow; return mf.maxFlow( 0, N + M + 1 ) == N; }