#include int min(int a, int b) { return (a 0) { matrix[0][0] += matrix[1][0]; matrix[1][0] -= matrix[2][0]; matrix[0][2] += min(matrix[0][0], matrix[0][1]); } else if(matrix[2][0] == 0 && matrix[0][0] > 0) { matrix[2][0] += matrix[1][0]; matrix[1][0] -= matrix[0][0]; matrix[2][2] += min(matrix[2][0], matrix[2][1]); } unsigned long long flow = matrix[2][2] + matrix[0][2]; /*if(A > B) { flow += B; res = A-B; if (C> res){ D+=res; }else{ D+=C; } if (D > E){ flow +=E; } else { flow += D; } }else { flow += A; res = B -A; } if(D > E && A < B) { flow += E; int res1 = D -E; if(C > res1) { if (res > res1){ flow += res1; }else { flow += res; } }else{ if (C < res){ flow+=C; } else{ flow +=res; } } }*/ if(flow < min_flow) min_flow = flow; } printf("%llu\n", min_flow); }